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

前端 未结 16 1680
抹茶落季
抹茶落季 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:55

    In order to compile and run a cpp source code from Mac terminal one needs to do the following:

    1. If the path of cpp file is somePath/fileName.cpp, first go the directory with path somePath
    2. To compile fileName.cpp, type c++ fileName.cpp -o fileName
    3. To run the program, type ./fileName

提交回复
热议问题