Ender
Ender

Reputation: 1

Problems with fflush(stdout);

I started programming and I learned about the command that is fflush(stdout);. I understand why I need it for most platforms, but I'm still asking myself some questions...

1.Isn't \n supposed to buffer on msys2 because it's line buffered? (Mintty)

2.Why do I need to use it on Eclipse while I don't need to use it on Clion?

3.Am I the only one struggling with that problem ESPECIALLY on Eclipse and Msys2?

Edit : 3.1. I'm asking because I don't need fflush(stdout); on my school's Windows computers. Why is that?

Upvotes: 0

Views: 1840

Answers (1)

Vishal B U
Vishal B U

Reputation: 27

[This answer is talking about fflush(stdin) and is not really an answer.
fflush(stdout) does not have undefined behaviour.]

fflush is used to clear the stdout buffer and it has undefined behaviour. Sometimes, fflush won't work and it is better to use fpurge instead.

For more information to your question about the behaviour on Windows, refer to this thread - How come fflush(stdin) function is not working?

Upvotes: -2

Related Questions