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.
cout << "hello";, no extra std::endl or std::flush needed. Is it because Visual Studio already taking care of this?cout output at first time.
printf("XXX\n");