Kay so I'm doing this because I really have nothing better to do not being able to play gunz and no one being home at the moment, so let's get started!
C++ is a programming language that almost all modern day operating systems are built off of. It is a series of commands that tells the hardware to build a virtual environment and make it do something. All code has a job, and until it's job is finished it will continue to run until it reaches it's end line conditions. An end line condition is a conditional statement that says, once ________ has done _________ do ________ . So let's say I make a basic program that tells the computer to:
Print a line of text; wait for user input; exit;
Here is a basic example of what that would look like in c++
=====================================
#include
using namespace std;
int main()
{
std::cout <<"This text will be printed\n";
system("pause")
return 0;
}
=====================================
-
-
-
-
=====================================
[output]
This text will be printed
Press any key to continue...
-
=====================================
Now if you don't get any of that code above the output, I'll explain
In the first line (#include) this tells the compiler that you are using to compile your code to use this to interpret it. There are many things you could #include, but almost all programs start with that particular line.
The second line is a native c++ command telling the compiler to use the std function which is a standard for all cout/cin lines. Basically what it does is allows me to type cout or cin instead of std::cout or std::cin and save me time if I'm going to be doing that a lot.
The third line (int main()) is our main function, and will be the block of code that is run first. In a lot of cases it'll be the only code that will be run, unless you're using multiple files that will be run in conditional statements.
The fourth line which is an open curly bracket tells the compiler, this is where the code starts, and this is where you need to execute things. The closed curly brackets at the bottom tells the compiler that it is the end of the code and that it can stop now, but on to line 5.
std::cout <<"This text will be printed\n"; , This line has a few c++ terms which may be confusing at first but I'll explain . First, cout: cout means Computer Out, it tells the computer to give some output of what it's being told to output. So if I told it cout << 5 * 2; , it would say 10. Anytime you want the computer to print text, you put it into quotation marks "like so". The \n before the end quotation marks means, this is the end of the line, anything after this should be printed on a new line. Finally the semi colon ; . Every line in c++ ends with a semicolon, this tells the compiler to move on to the next line and it makes it easier for the programmer to read the code.
The sixth line is a simple windows CMD command that will print the line "Press any key to continue..." This is useful if you want to see the output of your program because remember, once the program has done everything it is suppose to, it'll close. So the program won't close till the user presses a key . I'll explain this line though. If you were to make a .bat file, and type "pause" without quotation marks, and run it, it would simply say "press any key to continue...". Well c++ doesn't have a function to print that line, so what we do is we tell it to talk to system which is a phrase that tells the compiler to exec a windows .bat command. What this does is allows the programmer to do very simple tasks that would normally be difficult. You simply type, system() and inside the parenthesis you type the parameters, which are commands.
Lastly, as I explained up above, you end your main function with a closing curly bracket }.
Now I know this seems like a lot of work, but it really isn't, it's just hard for some people to understand without being completely walked through it. I myself didn't have much trouble learning basic programming since I'm very interested in logic and how things work . Really all programming is, is math with the addition of words. If you know algebra and calculus you'll probably have no problem learning any logical programming language ^_^.
If you're interested in this, I can point you in the direction of better tutorials and a compiler so you can learn to program too ! I hope you have enjoyed this HeeroGeekTut.
-Heero
C++ is a programming language that almost all modern day operating systems are built off of. It is a series of commands that tells the hardware to build a virtual environment and make it do something. All code has a job, and until it's job is finished it will continue to run until it reaches it's end line conditions. An end line condition is a conditional statement that says, once ________ has done _________ do ________ . So let's say I make a basic program that tells the computer to:
Print a line of text; wait for user input; exit;
Here is a basic example of what that would look like in c++
=====================================
#include
using namespace std;
int main()
{
std::cout <<"This text will be printed\n";
system("pause")
return 0;
}
=====================================
-
-
-
-
=====================================
[output]
This text will be printed
Press any key to continue...
-
=====================================
Now if you don't get any of that code above the output, I'll explain
In the first line (#include
The second line is a native c++ command telling the compiler to use the std function which is a standard for all cout/cin lines. Basically what it does is allows me to type cout or cin instead of std::cout or std::cin and save me time if I'm going to be doing that a lot.
The third line (int main()) is our main function, and will be the block of code that is run first. In a lot of cases it'll be the only code that will be run, unless you're using multiple files that will be run in conditional statements.
The fourth line which is an open curly bracket tells the compiler, this is where the code starts, and this is where you need to execute things. The closed curly brackets at the bottom tells the compiler that it is the end of the code and that it can stop now, but on to line 5.
std::cout <<"This text will be printed\n"; , This line has a few c++ terms which may be confusing at first but I'll explain . First, cout: cout means Computer Out, it tells the computer to give some output of what it's being told to output. So if I told it cout << 5 * 2; , it would say 10. Anytime you want the computer to print text, you put it into quotation marks "like so". The \n before the end quotation marks means, this is the end of the line, anything after this should be printed on a new line. Finally the semi colon ; . Every line in c++ ends with a semicolon, this tells the compiler to move on to the next line and it makes it easier for the programmer to read the code.
The sixth line is a simple windows CMD command that will print the line "Press any key to continue..." This is useful if you want to see the output of your program because remember, once the program has done everything it is suppose to, it'll close. So the program won't close till the user presses a key . I'll explain this line though. If you were to make a .bat file, and type "pause" without quotation marks, and run it, it would simply say "press any key to continue...". Well c++ doesn't have a function to print that line, so what we do is we tell it to talk to system which is a phrase that tells the compiler to exec a windows .bat command. What this does is allows the programmer to do very simple tasks that would normally be difficult. You simply type, system() and inside the parenthesis you type the parameters, which are commands.
Lastly, as I explained up above, you end your main function with a closing curly bracket }.
Now I know this seems like a lot of work, but it really isn't, it's just hard for some people to understand without being completely walked through it. I myself didn't have much trouble learning basic programming since I'm very interested in logic and how things work . Really all programming is, is math with the addition of words. If you know algebra and calculus you'll probably have no problem learning any logical programming language ^_^.
If you're interested in this, I can point you in the direction of better tutorials and a compiler so you can learn to program too ! I hope you have enjoyed this HeeroGeekTut.
-Heero
Last edited by Heero on Tue 27 Oct 2009, 6:19 pm; edited 1 time in total
Mon 10 Jun 2019, 1:40 am by Darylin
» Obviously this site is inactive, find us here ---
Mon 10 Jun 2019, 1:38 am by Darylin
» Obviously this site is inactive, find us here ---
Mon 10 Jun 2019, 1:36 am by Darylin
» Obviously this site is inactive, find us here ---
Mon 10 Jun 2019, 1:36 am by Darylin
» Obviously this site is inactive, find us here ---
Mon 10 Jun 2019, 1:34 am by Darylin
» Obviously this site is inactive, find us here ---
Mon 10 Jun 2019, 1:33 am by Darylin
» Anyone alive?
Mon 11 Feb 2013, 11:52 am by Bullets31222
» Y U NO ONLINE?!
Sat 01 Oct 2011, 10:55 am by Darylin
» ~Vindictus~
Wed 20 Jul 2011, 1:41 am by Xinuix