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

后端 未结 9 2173
渐次进展
渐次进展 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 01:54

    To do this:

    1. open terminal

    2. type in the terminal: nano ; which is a text editor available for the terminal. when you do this. something like this would appear.

    3. here you can type in your C program

    4. type in control(^) + x -> which means to exit.

    5. save the file by typing in y to save the file

    6. write the file name; e.g. helloStack.c (don't forget to add .c)

    7. when this appears, type in gcc helloStack.c

    8. then ./a.out: this should give you your result!!

提交回复
热议问题