简体   繁体   中英

Error running *.c file in Eclipse Kepler

I've started programming in C so weeks ago, and I choose Eclipse Kepler as my IDE for C, since I had already used it for programming in some other languages and really liked.

However, after I had installed Cygwin and the C programming tools in Eclipse, I tried to run the old "Hello World" and it didn't work, It didn't appeared anything in the Console, only the message "Terminated".

#include <stdio.h>

int main(){
    printf("Hello World!");
    return 0;
}

Anyone has any idea what the problem could be?


Thanks to all of you. I tried everything you said but I wasn't able to get my problem solved. I gave up! Right now, i'm using as workspace in eclipse the Cygwin home. I write the program in the Eclipse and run it in the Cygwin command line. Again, thanks to all for trying to help, it won't be forgotten. You're a really awesome crowd!

Maybe the program was too fast for you to see it?
The window with the program output appeared and disappeared in the blink of an eye.

You could try to prevent that from happening by changing your program to do its stuff AND wait for ENTER before it terminates.

#include <stdio.h>

int main(){
    printf("Hello World!");
    getchar(); /* simple wait for ENTER, error prone in more complicated programs */
    return 0;
}

Note: your original program "prints a string"; this version "prints a string and waits for ENTER". It's a program with different requirements. If you want to keep to your initial requirements, try running the program from the DOS console.

you could try to system("pause") may this can help

#include <stdio.h>

int main(){
    printf("Hello World!");
    system("pause");
    return 0;
}

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