0
I am learning C and am locked in an exercise that asks to store the data as follows.
Student’s Grade and Student’s Name on the same line, and then with a chosen index determine the student’s status, the part of manipulating the index and checking his grade I know how to do, but I’m having problems with what it would be like to do this kind of problem using vectors in C that receive an integer and a string that passes to 2 vectors.
Data example:
8.0 Ed Rex
9.0 Marcos Vice
1.0 Alan Pequenuxo
That would be my code
include stdio.h
include stdlib.h
include string.h
int main()
{
int n,i;
int nota[99];
char aluno[20][30];
scanf("%d",&n);
for (i=0 ;i < n; i++){
scanf("%d %s",¬a[i], &aluno[i]);
}
return 0;
}
And what a problem you’re having?
– Maniero
This error appears when I try to compile. names. c: In Function ?main': names. c:12:10: Warning: format%s' expects argument of type ːchar ', but argument 3 has type ľchar ()[30]' [-Wformat=] scanf("%d %s",¬e[i], &student[i]); ^
– Fabricio
Exchange: &student[i] per student[i] in the scanf (take the &).
– Anonimo
thanks friend, I can’t believe it was just because of that. but if I wanted him to keep his surname, what could I do?
– Fabricio