I have a problem that when the users type same id,they need to type name and id again. How can i only ask the users to input the id rather than both name and id,when the users type same id number.Please give me some hints how to do that.Thanks for your help!
struct student
{
char student_name[30];
char student_id[10];
int student_course_num[20];
int student_course[10];
};
int main()
{
int student_num;
printf("Enter the number of students:");
scanf("%d",&student_num);
fflush(stdin);
struct student S[student_num];
char TestForId[student_num][10];
int i,j,student_code=1;
for(i=0;i<student_num;i++)
{
printf("Enter the name of student:");
fgets(S[i].student_name,30,stdin);
printf("Enter the Student ID (8 digits):");
fgets(S[i].student_id,10,stdin);
strcpy(TestForId[i],S[i].student_id);
for(j=0;j<i;j++)
{
if(strcmp(TestForId[j],S[i].student_id)==0)
{
printf("The student id has already exit\n");
}
}
student_code++;
}