Hello, I am new here and this is my first post. Was doing some assignment to take in multiple strings inputs but in the meantime, each character in the string is important. So I tried using fgets. sample program: for(num = 1; num<5; num++) { printf("Enter 8 characters: "); fgets(string, 8, stdin); printf("%c\n", string[3]); } However the output I got is: *blue* my input Enter 8 characters: abcdefgh d Enter 8 characters: d Enter 8 characters: *waiting for my input* How come the fgets does not wait for my second input during the second loop and just proceed on. Is there a way to solve this or actually there is another solution beside fgets that can solve my problem Thanks a lot
simply use fflush(stdin); after your fgets statement (or) use gets(string) instead of fgets I think your problem will be solved once check it out