Hello everyone. I am having a trouble with storing first and last names into the string, the program stops after it asks to type the first name in.
here is the function
Code:
struct student get_student_number_and_name(struct student X[MAX], int y)
{
int i, valid, num;
for(i=1; i<=y; ++i)
{
do{
valid=0;
printf("\n\nEnter student %i - # ", i);
scanf_s("%i", &num);
if(X[i].student_num==0)
{
X[i].student_num=num;
printf("First name: ");
scanf_s("%s", X[i].first_name); //it stops here.
printf("Last name: ");
scanf_s("%s", X[i].last_name);
}
else
{
printf("Student Number has been entered! Try agin!");
valid=1;
}
}while(valid!=0);
}
return X[MAX];
}
I do no see why it stops. I will be very ppriciated if anyone can point where I am wrong.
Thank you.