Sublime Forum

C compiler. Build OK. Doesn't appears the "hello world" in console

#1

Hi i have this build

{ "build_systems": [ { "file_regex": "(.+[^:]):(\\d+):(\\d+): (?:fatal )?((?:error|warning): .+)$", "name": "mybuild", "shell_cmd": "gcc -Wall -O2 main.c -o myapp", "working_dir": "${project_path}" "selector": "source.x", } ], "folders": [ { "path": "." } ], "settings": { } }

when i build this

#include <stdio.h> int main(int argc, char const *argv[]) { printf("Hello\n"); getchar(); return 0; }
its appears
[Finished in 0.4s] but not the “hello”

0 Likes

#2

Are you the same guy as below?

Anyway, it’s becuase you’re not flushing the stdio output buffer.

0 Likes

#3

not i am not… but i took the build from that thread… and i am new in coding,
as i understand i must have a folder named myapp in my desktop, save the build there and also me src there?

0 Likes

#4

As i see, nop… i tryied this but nothing. i just dont know what is flushing the stdio output buffer and how to

0 Likes

#5

OK, so now I notice you’re just building the source, not running it. Have a look at the linked thread above where they explain how to run it. If it’s still not outputting then flush the buffers, which, using the magic of google, I found out how to do here:

0 Likes

#6

ok, i ll do it now, thank you

0 Likes

#7

This does not seem to be clear in this thread. You can change the shell command to
"shell_cmd": "gcc -Wall -O2 main.c -o myapp && ./myapp",
to execute the file after building it.
(On windows use: "shell_cmd": "gcc -Wall -O2 main.c -o myapp.exe && myapp.exe",

1 Like