Deebow's C++ TuT for begginers! How to make your first program!

Posts 1–14 of 14 · Page 1 of 1
Deebow's C++ TuT #1---for beginers! How to make your first program!
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.

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");
}
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!)

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!

Code:
// Your first program in C++
That is a comment! Any line beggining with // is only for you to read and will not effect the code or program!

Code:
#include <iostream>
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.- Zhao


Code:
using namespace std;
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:
int main ()
This tells the processor that the Following Code is the Main code of the program.

Code:
{
Opens the code, everything under this is a code for the program to run.

Code:
char *enter;
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:
cout << "Hello World!\n";
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 << "You just made your first C++ Program!\n";
This is a statement. Just as above. You can have as many statements as you want.

Code:
system("pause");
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:
}
End of 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?
Nice. I might try this out soon. I have never done anything with coding so its totally weird to me.
Noob friendly =D CMD = command prompt
Your tut needs a little fixing up.

Code:
#include <iostream>
This tells the compiler to include the iostream header file which contains the cout function and standard input/output functions

Code:
using namespace std
This is the standard namespace, without this you would have to do
Code:
std::cout<<"Hello Wordl!";
So its for lazy coders
Code:
cout<< "Hello World!\n";
This outputs Hello World to the screen. The '\n' character makes a new line, but it cna be substituted by this:
Code:
cout<<"Hello World!<<endl;
endl is a macro for new line;
Code:
system("pause");
System(" ") actually means anything in the brackets will be treated as a command line. If you know your command prompt commands you can put it in the brackets. Try typing in "pause" without the quotations into command prompt
Zhao is always there to find error :P And I think he's always able to find one XD But nice job for the TuT
Nice Tutorial Deebow and thx for the folow up zhao.

BTW: what I don't understand the "namespace std" thing? Seems like it is there just for the hell of it o_O?
Using namespace std

Is like zhao said. With it you can simply put

cout << "hi" << endl;

but without it you have to put

std::cout<<"hi";
Thanks! I found this very easy to follow, this is a great Tut, and i look foward to viewing your future tuts.
you can do tht in notepad if u save it as .bat good tut anyway lol
deebow, make a tut for writing dll files.
Yeah I made this guide so that anyone could understand it. I hate guides that expect you to know things, Like longevitys d3d9 chams tutorial... Its like making a golf guide that only Tiger Woods could understand...
Lol thank you nice tut it helps a lot noobs like me in the making of hacks lol but i have a problem when i try to compile it a message pops out saying: The system cannot find the file specified. And it would not let me save it or open it. Please someone help! What should i do?
Quote Originally Posted by AlboHacker View Post
Lol thank you nice tut it helps a lot noobs like me in the making of hacks lol but i have a problem when i try to compile it a message pops out saying: The system cannot find the file specified. And it would not let me save it or open it. Please someone help! What should i do?
Btw, to fix your problem, it seems your missing a file, or your misspelled a file name. Just either re-install your IDE, or check your program for mistakes.
Way to revive a thread. Why, where the hell are you? While your on vacation, we're going through hell.
Every time you bump an old thread...a small child gets raped by why06.

Please, save the children.
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?