Eclipse's quick fix for printf of not being output to the console

  • 2020-04-02 01:53:35
  • OfStack

The Eclipse console often fails to output printf of C properly, because the output content stays in the output buffer and does not output to the console interface in time. The solution is simple: add fflush (stdout) after each printf, or, like me, encapsulate printf with a macro:

#define OUTPUT_STR(str) do{printf(str);fflush(stdout);}while(0)

Related articles: