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

后端 未结 9 2179
渐次进展
渐次进展 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:04

    1) First you need to install a GCC Compiler for mac (Google it and install it from the net )

    2) Remember the path where you are storing the C file

    3) Go to Terminal and set the path

    e.g- if you have saved in a new folder ProgramC in Document folder

       then type this in Terminal
        cd Document
        cd ProgramC
    

    4) Now you can see that you are in folder where you have saved your C program (let you saved your program as Hello.c)

    5) Now Compile your program

       make Hello
       ./hello
    

提交回复
热议问题