Segmentation fault: 11 on c program
In my code:
int nAlunos, nNotas;
/*size input*/
scanf("%d", &nAlunos);
scanf("%d", &nNotas);
/*arrays*/
char listaNomes [nAlunos][16];
float listaNotas [nAlunos][nNotas+1];
/*non-arrays*/
int i, k;
/*input*/
for(i = 0; i < nAlunos; i++){
scanf("%s", listaNomes[i]);
for(k = 1; k <= nNotas; k++){
scanf("%f", &listaNotas[i][k]);
}
}
I am trying to fill a table of data from the user, I may not use pointers
for this class.
it needs to receive data as presented:
String1
float1 float2...
String2
..
..
..
When running it, it works well until I finish with the last input. After
that it just breaks the execution and returns me segmentation fault: 11
I tried to find where could it be accessing improper memory, but it just
doesn't make sense to me because I cannot find it.
No comments:
Post a Comment