Hello, the simple thing with eclipse is to receive scanf("%d", & variable name), but the output is pushed out one space at a time

Asked 2 years ago, Updated 2 years ago, 50 views

In this way, the Im a student should come out first and the input should come out

I haven't used scanf many times, but it's hard to find even if I google it ㅠ<

I'd appreciate it if you could give me some advice

I'm using epse and mingw.

c eclipse

2022-09-22 19:37

1 Answers

This is because of the output buffer.
The buffer hasn't been emptied yet, so it looks like scanf came out before the output.

fflush(stdout);

Force the buffer to empty using fflush before scanf.
I am attaching a link for your reference.
C language coding painting: utilizing input/output buffers


2022-09-22 19:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.