Error in the average calculation of a student record

1
printf("Nota 1: ");
scanf("%.1f", &alu[n].not1);

printf("Nota 2: ");
scanf("%.1f", &alu[n].not2);
alu[n].media = (alu[n].not1+alu[n].not2)/2; // o erro acontece NESSA LINHA
  

invalid operands to binary + (have 'float *' and 'float *')

I always get error on the highlighted line with comment, can anyone tell me why?

    
asked by anonymous 02.11.2017 / 21:40

1 answer

2

Change structure for this to resolve:

typedef struct {
    int matricula;
    char nome[80];
    int datanasc;
    float not1;
    float not2;
    float media;
    Data aniv;
} Alunos;

I placed GitHub for future reference.

Only the string must be an array of characters. The way it was it had 3 notes each, which does not look like it is what you want. I understood that I wanted it to have 3 digits. A floating point number has its own format and you do not control its size. What you can do next is to limit the textual representation of the number to display only what you want.

I think you may still have other problems there, as the birth date being an integer, but you're who knows what you're doing. I hope it exists and knows how to deal with type Data . Besides being weird having a birthday and birth date.

    
02.11.2017 / 21:55