In CodeLite, when I run my program, none of the messages I write to stdout or stderr appear in the "Output" tab. My test program is as follows:
#include <stdio.h>
int main()
{
puts("Writing to file...");
FILE* fp = fopen("test.txt", "w");
fprintf(fp, "hello world\n");
fclose(fp);
return 0;
}
Here's the build output: Build output
And here's the run output: Run output
The file "test.txt" is created and the text "hello world" is present. However, the "Writing to file..." text isn't printed to the output.
If I run the program from the terminal I see this output just fine, so it must have something to do with CodeLite.
There seem to be people who have experienced similar issues, but unfortunately the solutions they have don't work for me:
- CodeLite - Console runs but code is not working
- Codelite C++ program not compiling and running
- Output from cout or printf in C++ not showing in CodeLite on Windows 7
It has been suggested that I am not flushing stdout here:
I have tried this using fflush(stdout);
but to no avail.
I am running on Linux.
Can someone help?