Estou tentando alterar um elemento de uma struct em uma função,porém está dando o seguinte erro:
incompatible types when assigning to type ‘CADASTRO’ from type ‘int’
#include <stdio.h> #include <stdlib.h> typedef struct{ int matricula; float salario; char nome[30]; }CADASTRO; int main() { CADASTRO cad[100]; int i=0,j,mat; FILE *arquivo; int opcao; do { menu(); printf("\n\n OPCAO: "); scanf("%d",&opcao); if(opcao == 6) break; switch(opcao){ case 1: incluir(&arquivo,&cad[i]); i++; break; case 2: printf("\n DIGITE O NUMERO DA MATRICULA QUE DESEJA ALTERAR: "); scanf("%d",&mat); for(j=0;j<100;j++){ if(mat==cad[j].matricula) { cad[j]=alterar(); } } break; case 3: break; case 4: break; case 5: break; } }while(opcao != 6); } void menu() { printf("\n --------------------------------- CADASTRO ------------------ ------------------\n"); printf("\n 1- PARA INCLUIR CADASTRO"); printf("\n 2- PARA ALTERAR CADASTRO"); printf("\n 3- PARA EXCLUIR CADASTRO"); printf("\n 4- LISTAR TODOS OS CADASTROS"); printf("\n 5- PARA LISTAR UM DETERMINADO CADASTRO"); printf("\n 6- PARA SAIR"); } void incluir(FILE *arquivo,CADASTRO *c) { char lin[75]={"------------------------------------------------------------- --------"}; fflush(stdin); arquivo=fopen("cadastro.txt","a"); if(arquivo==NULL) { printf("\n ARQUIVO NÃO PODE SER ABERTO"); exit(0); } printf("\n\t\t ARQUIVO ABERTO!\n"); printf("\n DIGITE O NOME: "); gets(c->nome);fflush(stdin); printf("\n DIGITE A MATRICULA: "); scanf("%d",&c->matricula);fflush(stdin); printf("\n DIGITE O SALARIO: "); scanf("%f",&c->salario);fflush(stdin); fprintf(arquivo,"\n%s\n",lin); fprintf(arquivo,"NOME: %s\n",c->nome); fprintf(arquivo,"MATRICULA: %d\n",c->matricula); fprintf(arquivo,"SALARIO: %5.2f\n",c->salario); fprintf(arquivo,"\n%s\n",lin); fclose(arquivo); } CADASTRO alterar(FILE *arquivo) { CADASTRO c; arquivo=fopen("cadastro.txt","a"); if (arquivo==NULL) { printf("\n ARQUIVO NAO PODE SER ABERTO!"); exit(0); } printf("\n\t\t ARQUIVO ABERTO!\n"); printf("\n DIGITE A NOVA MATRICULA: "); scanf("%d",&c.matricula); return c; }