So like hello world:
1 2 3 4 5 6 7 8 9 10 11
|
#include<iostream>
#include<conio.h>
using namespace std;
int main (){
cout<<"Hello World!"<<endl;
_getch ()
return 0;
}
| |
would output this
/* these are comments, they are not actual code and do nothing other than help organise and explain code, these comments can span numerous lines*/
// these comments can only span one line
#include<iostream>
Allows for cout, cin, cerr and clog as well as others, it overloads anything in the iostream library (That was what I was told, I am sure some more advaced programmers can correct me but that is all you really need to know)
#include<conio.h>
Is from C, it allows _getch () in this instance
using namespace std;
Essentially says that we are using the std namespace, I would do a little research into that if I were you. The other options is to use
std::cout<<"Hello World!"<<std::endl;
or to declare every one like this:
1 2
|
using std::cout;
using std::endl;
| |
int main ()
Makes a main function that returns type int (or so I am told), that is why at the end we have
return 0;
The moment all of the main functions code is over the program ends.
cout<<"Hello World!"<<endl;
Prints "Hello World!" on to the out put and ends the line.
_getch ()
Waits for input so that the program does not close near immediately, without waiting for the keypress the code would be over befor you could even manage to read the output. It is also a way of inputting text in C.
Or do you know all of that and I wasted alot of time?