Compiling C and C++ programs

  1. Use an editor such as nedit, vim, or emacs:
    "nedit &" leaves the terminal window active

  2. C programs: gcc filename.c -o filename
    (or gcc -o filename filename.c)

  3. C++ programs: g++ filename.cpp -o filename
    (or g++ -o filename filename.cpp)

  4. Running C and C++ programs: ./filename
    (This is how to run executable files)