Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct flsal {
- char *nome;
- int matricula;
- float salario;
- };
- typedef struct flsal Folha;
- Folha *inserirDados(char *nome, int matricula, float salario);
- void exibir(Folha *funcionario);
- void imprimir(Folha *funcionario);
- int main () {
- Folha *bem10, *gabryel, *vitor;
- char nom1[]="Lucas", nom2[]="Gabryel", nom3[]="Vitor";
- bem10 = inserirDados("Lucas", 1610039, 1000.00);
- gabryel = inserirDados("Gabryel", 1610024, 900.00);
- vitor = inserirDados("Vitor", 1610069, 7000.00);
- /* bem10.nome = "Lucas";
- gabryel.nome= "Gabryel";
- vitor_rubens.nome = "Vitor";
- bem10.matricula = 20161610040;
- gabryel.matricula = 201616010024; //SUBSTITUINDO O PROCESSO ACIMA
- vitor_rubens.matricula = 20161610069;
- bem10.salario = 1000;
- gabryel.salario = 900;
- vitor_rubens.salario = 7000; */
- /* printf("%s >>", bem10.nome);
- printf("%d >>", bem10.matricula);
- printf("%f \n", bem10.salario);
- printf("%s >>", gabryel.nome);
- printf("%d >>", gabryel.matricula);
- printf("%f \n", gabryel.salario);
- printf("%s >>", vitor.nome);
- printf("%d >>", vitor.matricula);
- printf("%f \n", vitor.salario); */
- return 0;
- }
- Folha *inserirDados(char *nome, int matricula, float salario){
- Folha *funcionario;
- funcionario = (Folha *) malloc(sizeof(Folha));
- funcionario -> nome = *nome; // = (*funcionario).nome = *nome;
- funcionario -> matricula = matricula; // "
- funcionario -> salario = salario; // "
- return funcionario;
- }
- void exibir(Folha *funcionario) {
- printf("%s >> %d >> R$%.2f \n", funcionario -> nome, funcionario -> matricula, funcionario -> salario );
- }
- void imprimir(Folha *funcionario) {
- FILE *file;
- file = fopen("dadosFuncionarios.txt", "a"); //r - read / a - alter
- fprintf(file, "%s >> %d >> R$%.2f \n", funcionario -> nome, funcionario -> matricula, funcionario -> salario);
- fclose(file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement