简体   繁体   中英

Cygwin gcc compiling and running, but doesn't printf anything

I'm just starting with C and installed Cygwin with GCC compiler on Windows. I tried running this Hello World program.

#include <stdio.h>

int main(void)
{

    //fflush(stdout);
    //setlinebuf(stdout);
    //setbuf(stdout, 0);
    printf("Hello World!\n");
    return 0;
}

The code compiles fine but when I try running it with ./ there is no output. I have tried to fix it using the commented lines (obviously I uncommented before running) but still had no output.

Name your source code file hello.c . In Cygwin bash shell, go to the directory where the source file hello.c is. Run gcc -o hello.exe hello.c . This will produce the executable hello.exe in the same directory. Then run ./hello .

Hope this helps.

this may be due to dll missing

add the cygwin dlls in your path, ie

d:\cygwin1.7.9[1]\cygwin\bin\

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM