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

前端 未结 16 1688
抹茶落季
抹茶落季 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 17:00

    just enter in the directory in which your c/cpp file is.

    for compiling and running c code.

    $gcc filename.c
    $./a.out filename.c
    

    for compiling and running c++ code.

    $g++ filename.cpp
    $./a.out filename.cpp
    

    "$" is default mac terminal symbol

提交回复
热议问题