Your program is running, but you won't see any output from your program because the output is buffered.
The output is buffered because the string that you have outputted with printf()
is not delimited by a newline at the end. The standard library will buffer the output until a newline is outputted or until you explicitly call fflush()
on the output stream. This buffering is done for efficiency.
One solution is to either output the string with a newline at the end:
printf("Enter an integer:\n");
... or to explicitly call fflush()
:
printf("Enter an integer: ");
fflush(stdout);
However, the correct way of doing it is to output any text intended for user interaction on the standard error stream, like most other Unix utilities do:
fprintf(stderr, "Enter an integer: ");
The standard error stream is unbuffered by default.
The other printf()
statements in the code suffers from the same issue and should probably have newlines appended to the strings they output (as they output the result, not user interaction messages).
See also:
\n
at the end of the printf string. – Paul_Pedant Dec 21 '21 at 16:255
and see what happens ! If not, just putprintf ("Hello, World.\n"); return (0);
as the first line undermain
. If it can't even do that right, your IDE is broken. – Paul_Pedant Dec 21 '21 at 17:34