Code:
#include<stdlib.h>
#include<string.h>
struct aluno{
char name [40];
const char grade[40];
const char name2[40];
int student_id;
};
void setAluno (struct aluno x[]);
void showAluno (struct aluno x[]);
main(){
struct aluno sujeito[2];
setAluno(sujeito);
showAluno(sujeito);
}
void setAluno (struct aluno x[]){
int i;
for (i = 0; i < 2; i++){
printf("\nEnter with Student ID %student: ", i+1);
scanf("%d", &x[i].student_id);
printf("Enter with the name %student: ", i+1);
scanf("%s%*c", &x[i].name);
printf("Enter with the grade: ", i+1);
scanf("%s%*c", &x[i].grade);
}
}
void showAluno (struct aluno x[]){
int i;
char name2;
printf("\nEnter with the grade: ");
scanf("%s%*c",name2);
for (i = 0; i < 2; i++){
if(strcmp(name2,x[i].name)==0){
printf("Id: %d Name: %s\nGrade: %s\n" , x[i].student_id, x[i].name, x[i].grade);
}else{
printf("dosen't have students in this grade \n\n");
}
break;
}
system ("pause");
}
it doesn't work..........i wanna show the students that are scribed in one grade
for example
id1 : 11
name 1 : wesley
grade: Math
id2: 12
name2: Robert
grade: English
Enter with the grade:
Math
id: 11 name: wesley grade:math