Can anyone tell me what I'm doing wrong? I need to store the data of 3 people in struct and then print it.
This error is appearing:
request for member 'name' in something not a structure or union
request for member 'age' in something not a structure or union
request for member 'weight' in something not a structure or union
request for member 'height' in something not a structure or union
request for member 'vector' in something not a structure or union |
But I did not understand what's wrong yet.
#include <stdio.h>
#include <stdlib.h>
int main() {
struct pessoas {
char nome[20];
int idade;
float peso;
float altura;
};
struct pessoas usuario[3];
int i;
for (i=0; i<=2; i++)
{
printf("\n");
printf("\nDigite seu nome: ");
gets(usuario.nome);
printf("\nDigite sua idade: ");
scanf("%i", &usuario.idade);
fflush(stdin);
printf("\nDigite seu peso: ");
scanf("%f", &usuario.peso);
fflush(stdin);
printf("\nDigite sua altura: ");
scanf("%f", &usuario.altura);
fflush(stdin);
}
for (i=0; i<=2; i++)
{
printf("\n%s, com %i anos voce pesa %.2f e tem %.2f de altura!", usuario.vetor[i], usuario[i].idade, usuario[i].peso, usuario[i].altura);
}
printf("\n\n");
return(0);
}
Thank you in advance. ;)