Home > Software engineering >  C Compiled Executable Not Running
C Compiled Executable Not Running

Time:11-09

I wanted to run an Hello World program as I am starting in C :

#include <stdio.h>
int main(){
        printf("Hello World\n");
        return 0;
}

I compile it with this command : gcc h4.c -o h4

It create the executable h4 and when I click on it the command prompt pop and get shut down directly its like its running but to quick for me to see before it shut down.

CodePudding user response:

use the command ./h4 in your command prompt to run the program but keep the prompt open. Clicking on the executable also does "runs" the program, but it closes the window after the execution is finished.

Seems like you are on Windows. In this case, you don't need the prefix ./,just simply h4.exe. Or, if you really want to, you can use .\.

CodePudding user response:

If you are not running it on your command prompt do this:

#include <stdio.h>
#include <conio.h>

int main(){
    printf("Hello world\n");
    getch();
    return 0;
}

Assuming your on windows, you should just type h4 instead if you want to run it on your command prompt.

  •  Tags:  
  • c
  • Related