2

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:

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?

Community
  • 1
  • 1
TheComet
  • 31
  • 4
  • what happens if you add carriage return? printf("Writing to file...\r\n"); – MathiasE Dec 08 '16 at 12:20
  • Just tried it, it doesn't change anything unfortunately. I should mention that this is linux and not Windows (question edited) – TheComet Dec 08 '16 at 12:36
  • Seems to me that CodeLite is not sending the string to stdout file descriptor, but somewhere else. Might be a configuration thingy. Look and see if CodeLite has some functions like "_write" and "_read", could give some hints.. – MathiasE Dec 08 '16 at 14:51
  • Any Answer to this one? .... I just started to use it, I got the exact same thing. Then I realised that a terminal was being opened and run behind the IDE window. I then clicked the "Pause when execution ends" option and the terminal behind stayed open and I could see my output. But its annoying that the "output" tab does not show anything - that is where I wanted and expected my output to go... – code_fodder Jul 20 '18 at 23:00

0 Answers0