I'm using gdb in RedHat to debug C++ code. To better debug my code, I added printf("XXX")
.
However, after the execution of printf("XXX")
, the gdb console didn't show XXX.
Other parts of my code works fine.
It's likely that your output is line-buffered, and because you didn't end the print with a newline, the output hasn't been flushed. Three easy fixes:
std::printf("XXX"); std::fflush(stdout);
std::printf("XXX\n");
std::puts("XXX");
Also, take care if you're mixing C-style FILE*
i/o with C++-style streams.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With