1
I cannot run a program that needs functions to execute a procedure, this function receives a vector of type struct by means of a pointer. There is no build error, but the program hangs while running and does not work. How I use all this together: pointer, vector, function and struct. Grateful.
struct dataNasc{
int dia;
int mes;
int ano;
};
struct RgAluno{
char nome[35];
float nota[4];
float media;
struct dataNasc dn;
};
void ler(struct RgAluno* Aluno[]){
int i;
int j;
for(i=0;i<2;i++){
Aluno[i]->media=0;
}
for(i=0;i<2;i++){
printf("nome: ");
scanf("%s",&Aluno[i]->nome);
printf("data de nascimento:\ndia: ");
scanf("%d",&Aluno[i]->dn.dia);
printf("mes: ");
scanf("%d",&Aluno[i]->dn.mes);
printf("ano: ");
scanf("%d",&Aluno[i]->dn.ano);
for(j=0;j<4;j++){
printf("nota %d: ",j+1);
scanf("%f",&Aluno[i]->nota[j]);
Aluno[i]->media+=Aluno[i]->nota[j];
}
Aluno[i]->media/=4;
}
}
int main(){
struct RgAluno* Aluno[MAX];
ler(&Aluno);
return 0;
}
Is there a reason to make all this mess? Can’t you simplify? You can put the parts of the code that are missing?
– Maniero
There are missing parts friend, I solved as for the program to work, now I would like to know how to constitute a "pointer vector". Grateful
– Raphael Zanarelli