Hello, here is a code that should read a certain number of strings. The problem is that the program doesn't stop to allow entering the first string. I can only write string n°2, n°3 and so on.
Is it perhaps the scanf before the for cycle that causes problems?
Is it perhaps the scanf before the for cycle that causes problems?
Code:
#define maxnumber 10
void main()
{
char string[20];
int index, numb;
printf("\nHow many students? (less than %d) :", maxnumber);
scanf("%d",&numb);
for (index=0; index< numb; ++index)
{ printf("\nWrite name of student nr %d :", index+1);
gets(string);
}
}