C/C++ programming under Linux (a very basic introduction)

Revised 24/02/2008

On the University central Linux servers (gul3, gul4, gul5), the C/C++ compiler command is g++
though for simple compilations you can use the command: c

  $ edit hello.c
  ----------------------------------------
  #include <iostream>
  using namespace std;

  int main() {
    cout << "Hello World!" << endl;
  }
  ----------------------------------------
To compile the file 'hello.c'
  $ c hello.c
or use g++ with -o option
  $ g++ hello.c -o hello
To execute the file 'hello'
  $ hello

This will output "Hello World!".

Notes:

Creating and using libraries

First create the following example files:

sub1.c , sub2.c , sub3.c and main.c

system@gantep.edu.tr