Can anyone tell me why this code does not work? When i run, it just prints out \"Enter info about trail 1\" and without any input, skips to another step.
#in
Issue
The scanf function in main reads the integer, but leaves the newline \n
on the input stream. When the first loop iteration of readingArrays
comes around, fgets
sees this newline and assumes you have already entered your trail info and pressed enter. It prints the empty string and newline, and goes on to the next iteration.
Solution
One solution would be to tell scanf
to read and ignore whitespace after the digit by adding a space after %d format specifier.
So to get numberOfTrails
from stdin, you would do
scanf("%d ",&numberOfTrails);
Thanks to @Ray for pointing out this solution!