How to run C program on Mac OS X using Terminal?

后端 未结 9 2153
渐次进展
渐次进展 2020-11-28 01:47

I am new to C. Here is my \"Hello,world!\" program.

#include 

int main(void)    
{
  printf(\"Hello, world!\\n\");
  return 0;
}
9条回答
  •  离开以前
    2020-11-28 02:13

    First make sure you correct your program:

    #include 
    
    int main(void) {
       printf("Hello, world!\n"); //printf instead of pintf
       return 0;
    }
    

    Save the file as HelloWorld.c and type in the terminal:

    gcc -o HelloWorld HelloWorld.c
    

    Afterwards just run the executable like this:

    ./HelloWorld
    

    You should be seeing Hello World!

提交回复
热议问题