Raid500
Forum Addict
- Joined
- Feb 11, 2007
- Sythe Gold
- 0
- Messages
- 592
Hello all, I am RAID and I am pretty good at programming/server coding/ect.. I am here to explain some basics of C++.
Start out by downloading a C++ compiler (Dev-C++) from CLICK HERE This compiler is free which is great because most cost a ton!
After you have downloaded it open it up and install.
Picture of the important buttons:
Now, open a new source file and you will notice that a box comes up. You will also notice that there is a few things already written in there.
The first line: #include <iostream.h> Anything starting with a # tells the processor what to do. This is were all the declare files are found.
The second line: #include <stdlib.h> This isn't as important as the first, so there isn't a point in explaining it.
The fourth line: int main() This is where all the important thing in C++ start out working (after this line)
The seventh line: system("PAUSE"); You will only need this if you use Dev-C++, all other programs don't need it.
The eighth line: return 0; This makes the program stop.
Now that you are more familiar with your compiler lets start learning some C++!
The main difference between C++ and Java is that you can do more mathematical things with C++ than with Java.
In C++ I use it a lot for math help (easy calculator). So now I'll teach you some of the signs.
Those are the equal signs that you can use.
Now:
This is actually x = x - 5; in C++. So in other words: The equal signs are stated to be used as so: x -= 5 would just be x = x - 5, nothing hard.
Now to get you started making some simple C++ programs (not really programs, but simple "accessories")
Now what this does.
The //Name Program does nothing with the program since it isn't after the int main () and it has // before it, so keep this in mind, anything with // before it doesn't show up in your program. Now skip down to the int name; (we already discussed the others), this is declares a variable, int which is called name. The next line is what the program asks when you open it. It will ask What is your name? Then the next line you will respond and answer. The cout from the line before is what the compiler reads to make your program spit out what you put after it. The cin is what makes the compiler know to wait for you to respond.
After you respond, the program closes. If you want anything more to talk with about to a bot (idk who would, but okay heres the rest)
The program would ask whats your name then it would ask another, now we are getting into more programming since we are using strings and making the bot copy what you say. The getline, is that bot copying your line.
PS: IF YOU SEE ANY ERRORS: PLEASE TELL ME AND I WILL FIX IT!
Thanks for reading,
RAID
Start out by downloading a C++ compiler (Dev-C++) from CLICK HERE This compiler is free which is great because most cost a ton!
After you have downloaded it open it up and install.
Picture of the important buttons:
Now, open a new source file and you will notice that a box comes up. You will also notice that there is a few things already written in there.
The first line: #include <iostream.h> Anything starting with a # tells the processor what to do. This is were all the declare files are found.
The second line: #include <stdlib.h> This isn't as important as the first, so there isn't a point in explaining it.
The fourth line: int main() This is where all the important thing in C++ start out working (after this line)
The seventh line: system("PAUSE"); You will only need this if you use Dev-C++, all other programs don't need it.
The eighth line: return 0; This makes the program stop.
Now that you are more familiar with your compiler lets start learning some C++!
The main difference between C++ and Java is that you can do more mathematical things with C++ than with Java.
In C++ I use it a lot for math help (easy calculator). So now I'll teach you some of the signs.
Code:
+ is addition
- is subtraction
* is multiplication
/ is division
Code:
+=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=
Now:
Code:
x -= 5;
Now to get you started making some simple C++ programs (not really programs, but simple "accessories")
Code:
//Name Program
#include <iostream>
int main ()
{
int name;
cout << "What is your name?";
cin >> name;
system("PAUSE");
return 0;
}
Now what this does.
The //Name Program does nothing with the program since it isn't after the int main () and it has // before it, so keep this in mind, anything with // before it doesn't show up in your program. Now skip down to the int name; (we already discussed the others), this is declares a variable, int which is called name. The next line is what the program asks when you open it. It will ask What is your name? Then the next line you will respond and answer. The cout from the line before is what the compiler reads to make your program spit out what you put after it. The cin is what makes the compiler know to wait for you to respond.
After you respond, the program closes. If you want anything more to talk with about to a bot (idk who would, but okay heres the rest)
Code:
#include <iostream>
#include <string>
int main ()
{
string string;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << string << ".\n";
cout << "What is your favorite food? ";
getline (cin, string);
cout << "I like " << string << " too!\n";
system("PAUSE");
return 0;
}
The program would ask whats your name then it would ask another, now we are getting into more programming since we are using strings and making the bot copy what you say. The getline, is that bot copying your line.
PS: IF YOU SEE ANY ERRORS: PLEASE TELL ME AND I WILL FIX IT!
Thanks for reading,
RAID

