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

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

    For compiling a c program on your latest macOS just type the following in terminal after saving the file with a .c extension and on reaching the path where the file is saved :

    cc yourfilename.c

    Once you have checked all the errors after compilation (if any), type the following for executing the code :

    ./a.out

    These commands are tested on macOS Mojave and are working perfectly fine, cheers coding!

提交回复
热议问题