PDA

View Full Version : Basics of C++



TheEliteOne
05-10-2010, 04:10 PM
Defines
---------



#include <iostream.h>
#define lol cout<<"Hello World!\n\n"; //Treats the word lol as "cout<<"Hello World!\n\n";

int main()
{
lol
system("pause");
}


Calling Functions
-------------------



#include <iostream.h>

void Function()
{
cout<<"World!\n\n";
system("pause");
}

int main()
{
cout<<"Hello ";
Function(); //Calls the function
}


Goto Commands
------------------



#include <iostream.h>
int main()
{
Start:
system("cls");
cout<<"Hello World!\n\n";
system("pause");
goto Start;
}


Strings
--------



#include <iostream.h>
#include <string>
using namespace std;

string x;

int main()
{
cout<<"Enter a word: ";
cin >> x;
system("cls");
cout<<"The word entered is: " << x << "\n\n";
system("pause");
}

tchanabc
05-10-2010, 07:40 PM
hey thanks c++ is hard but i learned something!

TheEliteOne
05-10-2010, 08:20 PM
hey thanks c++ is hard but i learned something!

No problem :D