Hello World

From E&E Students
Jump to: navigation, search

Type the following into the vim or anjuta editor's. Save the files and then compile the source programs. To compile from the command line use "gcc" or "g++". For example: "gcc main-cc.c -o main-cc".

Example 1 (main-cc.c) for GCC or C

 #include <stdio.h>

 int 
 main(int argc, char* argv[])
 {
    printf ("hello world\n");

    return 0;
 }

Example 2 (main-g++.cc) for G++ or C++

#include <iostream>

using std::cout;
using std::endl;

int 
main(int argc, char* argv[])
{
    cout << "hello world" << endl;

    return 0;
}