I wrote the following code:
int N; scanf(\"%d\", &N); int i; for (i = 0; i < N; i++) { char line[LINE_MAX]; if (fgets(line, LINE_MAX, stdin) != NU
You can place a call to fflush() just after the scanf() like this:
fflush()
int N; scanf("%d", &N); fflush (stdin); int i; ... (rest of code)...
So the newline character ges erased from the stdin buffer and the next fgets() will stop to ask for input.
stdin
fgets()