MODS if theres a way I could be aloud to post a link to the bloodshed site so people can download Dev-C++ please tell me!
Im going to teach you all how to make a simple program with C++.
This TuT is for people who have never used C++ or Coded ever and wish to start!
First you will need to Download and install Dev-C++. It is a program used to write programs then convert them into actual executable programs. I had trouble and could not post the installer as an attatchment
Search for "bloodshed Dev-C++" and you should find it... Sorry im afraid to post any links as I dont wanna get banned and the stupid attatchment thing didnt work. You can pm me if you need a link
You can also search the web for a C++ compiler and use any program you want. I use Dev because it is easy to use and all the pictures in this TuT are from Dev so I reccomend using it. After you download Dev-C++ (or whatever compiler you wish to use) install it.
Now open up Dev-C++ and go to New>Source file.
What looks like a text document shoud open in the blank spot there. This is where your going to write the code for your program.
Copy and paste that into your new document in Dev-C++.( Looking at this code and typing it in yourself will help you learn better!)Code:// Your first program in C++ #include <iostream> using namespace std; int main () { char *enter; cout << "Hello World!\n"; cout << "You just made your first C++ Program!\n"; system("pause"); }
After you type it in (Or copy/paste -.-) It should look like that.
Now that you have your code in there you need to compile it! Go to Execute>Compile, click compile and a little window should pop up and ask you what you want to name your compiled program, Name it whatever you want .
After you compile it you can run it. The run option is in the same spot as the Compile one but heres another screenshot just in case you get lost
When you click run a CMD (Black box thing -.-) will pop up and it will tell you "Hello world!" "You just made your first C++ program!" As you can see in the code. Then you press any key and the CMD will close.
Tah Dah!!! You are on your way to becoming a C++ Coder! Now if you want to learn more besides just copy and pasting I will define those commands for you!
That is a comment! Any line beggining with // is only for you to read and will not effect the code or program!Code:// Your first program in C++
This is a preprocessor directive. They always start with the # sign and it comes before any code to tell the processor what it is going to need to do. This tells the compiler to include the iostream header file which contains the cout function and standard input/output functions.- ZhaoCode:#include <iostream>
This is used often used for more advanced C++ such as input/output and such. It is not really needed in this code but It fixes some errors that might occur so I usually use it.You will learn more about this later in C++.Code:using namespace std;
This tells the processor that the Following Code is the Main code of the program.Code:int main ()
Opens the code, everything under this is a code for the program to run.Code:{
Also not really needed in this simple program but it also fixes some errors that might occur so I reccomend keeping it.You will learn more about this later in C++.Code:char *enter;
This is a statement. Its what makes those magical words appear. Cout is what tells the processor that there is a statement coming up. << Has something to do with displaying the words . Cout and << are new features of the C++ language.Code:cout << "Hello World!\n";
This is a statement. Just as above. You can have as many statements as you want.Code:cout << "You just made your first C++ Program!\n";
This is what makes the program say "Press any key to continue" so you can close it when you are done. It also makes the program stay open because without it the program would display the statements and close.Code:system("pause");
End of code.Code:}
I hope you found this TuT useful and maybe I have created some future interest in coding for some of you
I plan to make more C++ Tutorials as I learn more myself.
If you have any problems post here I will help you!
Dont forget that handy dandy thanks button?