How to compile and run C/C++ in a Unix console/Mac terminal?

前端 未结 16 1596
抹茶落季
抹茶落季 2020-11-30 16:32

How can I compile/run C or C++ in Unix console or a Mac terminal?

(I know it, forget it, and relearn it again. Time to write it down.)

16条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 16:45

    Running a .C file using the terminal is a two-step process. The first step is to type gcc in the terminal and drop the .C file to the terminal, and then press Enter:

    username$ gcc /Desktop/test.c 
    

    In the second step, run the following command:

    username$ ~/a.out
    

提交回复
热议问题