1
I created a code for a college exercise that was running smoothly, but I forgot that one of the variables of struct
was a vector, and when I made a simple change everything changed. Virtually all functions are giving error. I can’t find the answer anywhere.
BEFORE (when it worked) it was like this:
struct turma{
int matricula;
char nome[15];
float nota;
float media;
char resultado;
}; typedef struct turma turma;
Then I switched to:
struct turma{
int matricula;
char nome[15];
float nota[5];
float media;
char resultado;
}; typedef struct turma turma;
And nothing else works. Follow the example of a function that has gone wrong:
void insere (turma alg[MAX])
{ int x,y;
float cont=0;
for (x=0;x<MAX;x++)
{ printf("\nInforme os dados do %iº aluno: ", x+1);
printf("\n\nMatrícula: ", x+1);
scanf("%d", &alg[x].matricula);
printf("Nome: ", x+1);
fflush(stdin);
scanf("%s", &alg[x].nome);
for (y=0;y<5;y++){
printf("%iº nota: ", y+1);
scanf("%f", &alg[y].nota);
cont = cont + alg[y].nota;
}
}
}
Last line error is error:
invalid operands to Binary + (have 'float' and 'float *')
You can add the error in the code Citation, to emphasize about the real problem. Also add the other codes at the beginning of the post in
code
, will highlight them, helps in understanding.– Florida