C++ Hello World: Difference between revisions
From D3xt3r01.tk
Jump to navigationJump to search
New page: ==YEY== So I decided to give OOP (Object Orientated Programming ) a chance. So I started from scratch with C++ ==Code== <source lang="C++"> #include <iostream> using namespace std; in... |
No edit summary |
||
Line 5: | Line 5: | ||
==Code== | ==Code== | ||
<source lang=" | <source lang="cplusplus"> | ||
#include <iostream> | #include <iostream> | ||
Revision as of 00:14, 5 July 2009
YEY
So I decided to give OOP (Object Orientated Programming ) a chance. So I started from scratch with C++
Code
#include <iostream>
using namespace std;
int main (void){
cout << "Hello world" << endl;
return 0;
}
Compile in linux with
g++ file.cpp -o helloworld
and run
./helloworld
would output
Hello world
More details
The #include <iostream> means include the "input output stream" library which gives us access to the 'cout' function. The namespace thingy is a lil bit more complicated. int main(void) means we're creating the main function with no parameters which will return an integer value ( notice the return 0 ). Cout is the function that outputs hello world on the screen and endl adds a endline character.