Jump to content

vector dentro um estrutura


suzy

Recommended Posts

tenho uma estrutura que e assim 😁

struct aluno {
       char nome[20];
       int idade;
       int vetor[3];// vetor com notas dos 3 periodos
       float media;
       };

como coloco valores dentro do vetor? da -me erro :S

fiz assim:


void inicializa(struct aluno a){
             int i;
             printf("nome\n");
             scanf("%s",&a.nome);
             printf("idade\n");
             scanf("%d",&a.idade);
             for(i=0;i<3;i++){
                 printf(" valor %d\n",i+1);
                 scanf("%d",&(a.vet[i]));
                 }
             printf(" a media\n");
             scanf("%f",&a.media);
             }

void lista(struct aluno a){
         int i;
         printf(" nome\n",&a.nome)
         printf(" idade\n",&a.idade);
         for(i=0;i<3;i++){
                 printf(" valor %d\n",i+1);
                 printf("%d\n",a.vet[i]);
                 }
         printf("%f\n",a.media);
         }
         
main()
{
struct aluno a;
inicializa(&a);
lista(&a);

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.