#include <stdio.h>
int main(int argc, char *argv[])
{
int loop;
char name_array [20][30];
char course_array [20];
for (loop = 0; loop < 4; loop++)
{
puts("Enter name");
gets (name_array[loop]);
puts("Now enter course");
scanf("%c", &course_array[loop]);
}
}
The above is a code fragment that doesn't work as I want. The gets function will accept a string on the first iteration but after that the program skips gets and goes directly to the puts and scanf. Why is this? IF the puts and scanf are removed the loop works ok and I can complete the array. What is going on here or am I going crazy.