Important alert: (current site time 7/15/2013 4:42:11 PM EDT)
 

article

A C++ Tutorial for Complete Beginners # 1

Email
Submitted on: 7/28/2001 3:54:02 AM
By: Jared Devall 
Level: Beginner
User Rating: By 170 Users
Compatibility: C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Views: 356628
author picture
(About the author)
 
     I wrote this tutorial for those who wish to fully understand things from the beginning. If something is not explained clearly or is incoherent, please let me know and I will try to fix it ASAP!

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				


I will continue to write these (If you people actually enjoy them.) until I come across things I do not yet fully understand.

First things first. To start programming you will need to get you a Compiler. There are several free as well as a few Commercial ones. Unless you have a few hundred dollars to buy the Commercial Compilers I suggest you get you a free compiler.

Here is a list of a few free compilers for Windows: Linux and Unix come with a C/C++ compiler(I think). Just make sure you installed it and read the manuals!

Okay. You'll need to download one of those compilers and read the manuals on them. I use Dev-C++. If you have some questions using that specific compiler I might be able to help.

Let's get on with the code Shall we?

Windows users: Open up Notepad.
Dev-C++ : Just open it up and click on the new file icon.
*nix: Open up your favorite Text Editor. :)


1: #include <iostream.h>
2:
3: int main()
4: {
5: cout << "Hello World!" << endl;
6: return 0;
7: }


Go ahead and copy that little piece of code. (Starting with #include and ending with the last } ) You can paste it or just type it up in the text editor. Save it as hello.cpp . The .cpp extention lets the compiler know it's a C++ Source File. To compile in Dev-C++ click on the compile icon or Execute->Compile.
Note: The Remove the numbers. They are there only to help analyze the code!
You will have to read the instructions on how to compile it in Compilers other than Dev-C++.


Congratulations! You are now a C++ Programmer!

On Windows Machines the application will close very quickly if you run it. THAT IS OKAY! We will learn how to fix that later.. The point is you got the program to compile! Now let's break down the code.

#include <iostream.h>

The first symbol is the pound symbol. It is a symbol to the preprocessor. (Any words that are links will link to another tutorial with definitions in it. For now it DOES NOT EXIST)
After that is the word include. Together #include tells the compiler to include a file into your program. It is just as you had written it in there yourself!
Iostream.h is called a header file and is included our program. Why? Iostream stands for Input-Output-stream and is needed for cout, which prints things to the screen. iostream.h is surrounded by a < and a >. This tells the compiler to search in the 'include' directory for the file. iostream.h can also be surrounded by Quotations like so: "iostream.h"
This tells the compiler to look in the current directory for the file. iostream.h is obviously not in your current directory so leave the greater than and less than sign there!

Line 2 is just a blank line. It's just there as a part of whitespace.

Line 3 is the beginning of the Actual Program. On it is the main() function. Every C++ program has a main() program. When your program starts it automatically calls main(). According to ANSI Standard we must state main() to be int. This will be discussed in another tutorial.

Line 4 begins the body of the main() function. All functions begin with an Opening brace ( { ) and a closing brace ( } ) just as main() does. Everything inbetween is considered to be a part of the function.

Line 5 is what the program is all about! The object cout is used to print a message to the screen. This is how cout is used:
You write cout followed by the output redirection operator ( << ). The operator is created by hitting shift-comma twice. Everything after the < is printed to the screen. (Or atleast tried to.) until it reaches a semi-colon. ;
endl is way to make the string go to a new line. You also put a \n in the string instead of using endl like this:

cout << "Hello World\n";

If you want a string of characters to be written to the screen you put your text between two Quotations: "Hello world!" like so! You then put a semi-colon at the end signifying the end of the statement. Semi-Colons are somewhat like an English period. It tells the compiler that a statement is over. You'll learn where to put them and where not to put them as we get further into the tutorials.

Line 6 is a return statement. It returns 0 to close the program. It also ends in a semi-colon. This will be discussed in more detail in a later tutorial!

Line 7 is just a closing brace and the end of our program. The closing brace is required to 'close' the function! That's the 'hello world' program fully explained. You can experiment with outputting text by simply making a couple more cout statements.

If anything is to complicated to understand or if I screwed up. >:) then be sure to let me know. Please let me know if you would like anything more, want something explained in a little more detail or whatever. I'll try my best to fix it! - JARED


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
7/28/2001 11:17:34 PMMark Lu

This is an almost perfect tutorial. I'll give you a rating of five! I love this. Even though I'm half intermedite in C++. This kind of thing starts it out. It would be better if you teach variables, scapnf, fprintf, printfm, and loops. I also need to learn how to make a window's program. Also how to color text, select text position, draw gifs, and buttons, etc.
(If this comment was disrespectful, please report it.)

 
7/29/2001 12:29:21 AMJared Devall

I appreciate your feedback. I don't really know much Win32api so I most likely won't be putting a tutorial on that. I'll teach variables in another tutorial. (Just the basics in this one) scanf fprintf and the others are mainly C so I doubt I'll get into those. But I will teach loops. :)

-Jared
(If this comment was disrespectful, please report it.)

 
7/29/2001 12:40:59 AMfatal

Mark... to make windows applications you have to learn Win32 API, and learn that stuff. Its WAY different than console, just get a good book.

And Jarid I thought i was a great example, i will also go with 5. I know my C++ tho, anyway its good for begginers.
(If this comment was disrespectful, please report it.)


 
7/29/2001 5:03:59 AMJared Bruni

win32 is easy :)
(If this comment was disrespectful, please report it.)

 
7/29/2001 5:04:51 AMJared Bruni

I like the way you structured your tutorial. So 5 globes
(If this comment was disrespectful, please report it.)

 
8/1/2001 2:56:30 AMPolat Kadir

I like this tutorial very much, and I hope I will find more instructions explained this way. Thank you,Jared!
(If this comment was disrespectful, please report it.)

 
9/7/2001 11:42:12 PMJames

yes, this is kinda embarresing, but i just made i small program using youy tutorial & code & no matter what the program always closes how do i fix that? =) sorry i am a hopeless newbie!
(If this comment was disrespectful, please report it.)

 
9/8/2001 12:34:24 PMJared Devall

Well you can open up your dos prompt. Go into the directory that the .exe is in and run it from there. The program will still close but you will be able to see the output because the dos window will still be open. :)
(If this comment was disrespectful, please report it.)

 
10/21/2001 8:07:41 AMwinsome pal

please send me more beginner instructons for c++ as iam interested to learn at this mail id- mr_winsome_4u@yahoo.com
(If this comment was disrespectful, please report it.)

 
11/15/2001 12:14:06 PMCuke

Hey Jared,
AWESOME tutorial. did a really good job explaining the basics. I gave it 5 globes. The only problem I can see is you havn't made more yet. :)
(If this comment was disrespectful, please report it.)

 
12/7/2001 2:39:08 AMBeginner

This is the 1st C++ thing I've made as I have only done VB in the past. Visual Basic's capabilities are very limiting so I wanna move on to a more complex language. Thank You!
(If this comment was disrespectful, please report it.)

 
1/15/2002 4:31:24 PMEric

This is Great! I'm native to VB and ASP so this realy helps me out for starters!
Thanks.
(If this comment was disrespectful, please report it.)

 
1/15/2002 4:32:23 PMEric

I give you: (glob x 5)
(If this comment was disrespectful, please report it.)

 
1/22/2002 6:30:53 PMTiki

Thanks for this great tutorial. I'm taking Basic C. I've never programmed before and the teacher moves so fast. Thanks to you I'm actually starting to understand. If you had loops and bubblesort I could actually get an "A". Thanks again.
(If this comment was disrespectful, please report it.)

 
3/17/2002 5:40:12 AMSandro Heinzelmann

Great tutorial... Just one question:
i did everything you said and it closes the window to fast when i run it,so i ran it in does. it does something but i can't see the text. It's only a blank line.
PS: I am a complete newbie...
(If this comment was disrespectful, please report it.)

 
3/17/2002 5:41:27 AMSandro Heinzelmann

with "i ran it in does" i meant i ran it in dos
(If this comment was disrespectful, please report it.)

 
4/18/2002 7:09:39 AMchuck otis

it is ausom that someone is willing to have stuff an absolute beginner can start to learn with. I am using win95 and got an error message that said does not recognize the code.
(If this comment was disrespectful, please report it.)

 
5/9/2002 2:19:22 AMSteel

if you want it to stay open:
#include
then at the bottom
put a cout:
cout <<
(If this comment was disrespectful, please report it.)

 
5/9/2002 2:23:37 AMSteel

uhh the whole thing didn't post, if I
did something wrong someone let me know
lol
(If this comment was disrespectful, please report it.)

 
5/10/2002 10:23:38 PMAlan

This tutorial rocks. I'm a newbie, and I don't understand all this confusing code...but I'm learning. Thanks!
(If this comment was disrespectful, please report it.)

 
5/11/2002 5:17:37 PMTommy

To do a pause at the end of your program (or anywhere else in your program) include and then write "system("PAUSE");" w/o the outer quotes where you want a pause. Dev c++ adds this in whenever you create a new file and VC++ (microsoft visual C++) does this without any coding by you (at least it does in version 6.0 which is all that i have used). hope this helps.
(If this comment was disrespectful, please report it.)

 
5/22/2002 9:11:26 PMJerry

Where is the second tutorial?
(If this comment was disrespectful, please report it.)

 
5/22/2002 9:44:51 PMJared Devall

Hmm? Everyone want and expecting a 2nd one? ( if you do, give me ideas. simple basic stuff... since this is beginner )
(If this comment was disrespectful, please report it.)

 
6/2/2002 3:43:08 AMnightwolf

Hey man. Im really glad that u took the time and tought some noobs like me 2 get the most important part - START.
Im v. v. grateful. 5 points
(If this comment was disrespectful, please report it.)

 
6/12/2002 5:49:50 AMayham

wondeful words can't speak my mind it's an excelent explaining for the (Hello World)Program no one can explain it much more thank you man.
(If this comment was disrespectful, please report it.)

 
6/19/2002 12:25:12 AMDevin

I am absolutely, completely new in any kind of programming except HTML. I can't figure out how to compile the code. when I open the Dev-c++, it looks just like the My Computer screen. There is no compile icon and no way to make a new file. Please help.
(If this comment was disrespectful, please report it.)

 
6/19/2002 12:26:26 AMDevin

But the tutorial was great with the code.
(If this comment was disrespectful, please report it.)

 
7/11/2002 12:17:26 AMhani

I still get confused with #include and #include
What the difference???
Please help me.
(If this comment was disrespectful, please report it.)

 
7/15/2002 9:49:59 PM(V)enace

for some reason Im getting an error when trying to compile this
(If this comment was disrespectful, please report it.)

 
7/28/2002 6:34:50 PMMngsk

Great tutorial, Im waiting for the second one.
I found a Hello Wolrd! sample in Dev-C++ and it is a little different and the window doesnt close. Can you tell me something about it?
(If this comment was disrespectful, please report it.)

 
7/30/2002 7:11:32 PMJuan C

Good article. It goes to the point.
(If this comment was disrespectful, please report it.)

 
9/18/2002 10:43:12 AM

I'm just beginning C++ and I've searched online for tutorials but this one by far is the most easy to understand tutorial for beginners. I Know a hell of alot more than I did before I read and studied youre article.THANKS ALOT
(If this comment was disrespectful, please report it.)

 
9/30/2002 8:06:55 AM

why does some c and c++ programs always close when you run it? making it impossible to view the results, unless u stick a getch() before closing the program. Any thoughts? Thanx.
(If this comment was disrespectful, please report it.)

 
9/30/2002 10:45:04 PM

Thanks for this. I'm only thirteen and most of the tutorials out there are using big words like syntext, parenthesis, ect. 5 Stars
(If this comment was disrespectful, please report it.)

 
10/7/2002 5:54:38 AM

The tutorial is just fine for the beginner. But if I want to print the messeage " Hello world" to the printer?

(If this comment was disrespectful, please report it.)

 
10/18/2002 12:38:24 PM

it is a brilliant tutorial and has realy helped me
(If this comment was disrespectful, please report it.)

 
10/19/2002 10:06:22 AM[SpiderMan]

This tutorial has helped me alot! I'll give you 5 globes, for this great work! :D
(If this comment was disrespectful, please report it.)

 
10/21/2002 9:04:31 AM

I am kindo new to this C++ thing. I'm used to VB. I like the tutorial. It's quite helpful. But I can't get my compiler to work. I have had numerous attempts to learn C++, but have only ever managed to read a book upto varables because I can't find the thing to compile the .cpp files. I have microsoft visual studio, please help!
(If this comment was disrespectful, please report it.)

 
10/25/2002 6:02:11 PM

Excellent tutorial. I am also a newbie trying to learn. Your tutorial was great. I found it to be very helpful.
(If this comment was disrespectful, please report it.)

 
11/16/2002 8:05:31 PM

I thought it was really good but, I'm still waiting for an explanation on how to keep the DOS window open when I run it.I'm also studying w/ a book and all the examples I run practically blink on and then they're gone.I'm using Windows Me.I saw some ideas in the other replies but, there is no precise procedure given just a couple of codes w/ no indication as to where to put them i.e what line etc.Can ya help me out please?
Obvious Noob Jae
(If this comment was disrespectful, please report it.)

 
11/16/2002 10:52:44 PMPatabugen

this is great, ive just been taught all this by someone else but now i really understand it :)
.
Thanx
(If this comment was disrespectful, please report it.)

 
11/29/2002 1:37:48 AM

You forgot to tell us how to get rid of Windows' flashing.
(If this comment was disrespectful, please report it.)

 
12/2/2002 5:54:04 PM

Alright I'm going to answer my own question.As for the 'blinking' .exe
Just add:
#
ON THE LINE AFTER
#
THEN ADD
system("PAUSE");
ON THE LINE BEFORE
return 0;
That's it.That's the simplest way I personally can think of to put it.
(If this comment was disrespectful, please report it.)

 
12/20/2002 8:59:48 PM

I'm just starting out, And this is a fantastic tutorial for someone who is learning C++ for the very first time:)
(If this comment was disrespectful, please report it.)

 
1/17/2003 9:15:49 PMMichael Skelton

just one thing to notem, it is a better practice to use your parenthesis on the same line as opening a function eg.
void main()
{
}
should be:
void main() {
}
say you hard 150 functions you method would create 150 more lines... thats called spaghetti programming mate.

(If this comment was disrespectful, please report it.)

 
1/17/2003 9:17:14 PMMichael Skelton

dont worry carrige returns didn't work ill just e-mail it to you....
(If this comment was disrespectful, please report it.)

 
1/21/2003 12:44:04 PMJay1_z

Yes, This is a good tutorial. It looks EXACTLY like a tutorial that I read recently. I think someone may have stolen it from you and put it in their book. If anyone wants to see Jared Devall's published work you can read it in 'Sam's Teach Yourself C++ Second Edition.' Great Job Jared!
(If this comment was disrespectful, please report it.)

 
1/30/2003 2:44:12 AM

If you #include you get the old-style C++ I/O system. To use the modern iostream library, which you really should be doing, use #include . Strictly speaking you also need to #include . The definitions for the Standard C++ Library are in the std namespace, so you'll have to change cout, endl to std::cout, std::endl to get it to compile.
(If this comment was disrespectful, please report it.)

 
2/14/2003 11:50:49 PM

Wow this tutorial was excellent. Im glad I found it, the other one I was working with gave me all the stuff but told nothing about all the words that were important. =P I had no idea why cout was in there or anything. Thanks this helped very much for a newb who is starting C++ and hoping to eventually make an MMORPG.
(If this comment was disrespectful, please report it.)

 
2/19/2003 5:08:01 PMmrJOY PINOY

thanks man, this refresshes my C++ knowledge, it has been years since i last made a program in C++. Now i'm trying ot re-study it for future use...thanks!
(If this comment was disrespectful, please report it.)

 
2/22/2003 1:08:35 AM

Dear Jared Devall (respected sir)

I am doing B.Com 1st yrs and also have computer knowledge in NIIT INSTITUDE in chennai(perambur) i have seen your website it very helpful to me and pls guide me very well
i have so many doubt about c++
give below:-

1.what is public and private code

2.what is constructor and destructor

3.i need full detail of the c++
thank you
with best regards
venky
(If this comment was disrespectful, please report it.)

 
3/1/2003 1:45:19 PM

I'm new to C++ (I've only "programmed" in HTML and a program called Turing)and this tutorial seems really good. the only problem is, even when using your recommended compiler (Dev-C++) I get at least 3 errors every time I try to compile. One of the errors even says "Dev-Cpp/HelloWorld.cpp:5: ` cout' undeclared (first use this function)"! If anyone can help me, i would greatly appreciate it.
(If this comment was disrespectful, please report it.)

 
3/5/2003 3:15:02 AM

Great Tutorial, I have to give it a 5/5 as it is as good or even better than the SAM C++ in 24 hours Chapter 1. ^_^
Personally, I like Borland Complier better than the Dev-Cpp Complier function.
(If this comment was disrespectful, please report it.)

 
3/6/2003 1:10:38 AM

Amazing! I have never used C or C++, or any real code for that matter, and I got this easily! Every beginner should start here. It may be basic in the barest sense of the word, but it has shown me the potential and open-endedness of C++. Thank you for writing and sharing this, Jared!
(If this comment was disrespectful, please report it.)

 
3/25/2003 3:49:20 AM

This is great man!...I wanna learn more stuff for Dev-C++, since i am coding a game...My old source code files were in VisualStudio! and i wrote them 2 years ago..and now for some reason i have forgotten everything.wow thanks man...basics are easier thanks for a little help in hand ;)
(If this comment was disrespectful, please report it.)

 
4/6/2003 12:31:02 AM

The article is very good, but there are something to be noted.
At first, when include a library, you should not add
(If this comment was disrespectful, please report it.)

 
4/6/2003 12:31:50 AM

The article is very good, but there are something to be noted.
At first, when include a library, you should not add ".h" according to the modern C++ style. Second, as you mentioned, Windows system would close the window as it finished. You can add a line "getchar();" at the end of your program, then you can see your message.

(If this comment was disrespectful, please report it.)

 
4/28/2003 3:57:41 AM

do it fast
(If this comment was disrespectful, please report it.)

 
4/28/2003 4:00:06 AM

Y should i sent my feedback if i am not getting any of ur material

(If this comment was disrespectful, please report it.)

 
7/18/2003 8:20:35 AM

can cygwin be a debuggler?
(If this comment was disrespectful, please report it.)

 
7/18/2003 1:30:19 PM

Awesome tutorial i'm accually learning C++ =D =D =D
(If this comment was disrespectful, please report it.)

 
7/29/2003 6:37:24 PM

Great work m8

this is l33t work :)
(If this comment was disrespectful, please report it.)

 
7/30/2003 5:18:00 AM

Very helpful
(If this comment was disrespectful, please report it.)

 
7/30/2003 4:36:02 PMChris Allen

Excellent tutorial, very easy to understand. Never seen C++ in my life till a day or two ago, and this has helped me understand it a little bit more. Very good way to start learning.
(If this comment was disrespectful, please report it.)

 
8/14/2003 10:13:04 PM

i am also 13 and am just starting out this is my first laugage and sorry to say this totoial didnt help me alot beacuse the code dosent work on my complier i went to the lnk
(If this comment was disrespectful, please report it.)

 
8/14/2003 10:26:06 PM

hi i am only 13 but im sorry but the complier you recommeded [Blooshed.com] doenst seem to work with you code has anyone else had this problem??????? im useing there new beta cause i got windows XP and it only works gor ME and down so could you tell me what to do any help would be appeciated alos i am very impatciate so get back to me ASAP plz thx bye the way besides for the code the tutorial is VERY good nicw work i no how to make a window but i cant get text in my window...maby i should check out the bloodshed site for a tutorial...??? ok get back to me ASAP thx!

(If this comment was disrespectful, please report it.)

 
8/14/2003 10:27:58 PM

sorry for the spelling before im intelagent just suc at spelling =P
(If this comment was disrespectful, please report it.)

 
9/5/2003 10:04:54 AM

Yes, this is a very good tutorial. What I really enjoyed most was the E-mail coments back and forth. Too often you find a tutorial that explains one way of doing something and that's it. I'm the type who likes to get to the bones of things and your comments really helped. I hope you continue this and in the future add more "by the way" comments. Globes don't determine your ability, what follows will speak for itself. Keep it up!!!

(If this comment was disrespectful, please report it.)

 
9/25/2003 1:04:47 AMJared Devall

Answers and Questions to the Tutorial & Comments! Ask and Answer: www.yuidesigns.net/~rendelven/
(If this comment was disrespectful, please report it.)

 
9/30/2003 3:43:55 PM

Jared, your tutorial rocks. It's the best one so far, no bull blabbling about needless code. But there is one problem: When I try to display the
(If this comment was disrespectful, please report it.)

 
9/30/2003 3:45:47 PM

Jared, your tutorial rocks. But there is one thing that I didn't get: Maybe it's because I run win98, but why doesn't the hello text display? I did everything as in the tutorial. The exe file functions 100%, but the text is not displaying. I even tried adding a getchar(); to the end of the code but it still doesn't work, I need help on that one. Anyways, good job on the tutorial.
(If this comment was disrespectful, please report it.)

 
10/16/2003 6:16:21 AM

Hi there
I think your tutorial is so useful for biginer. Actually, I am a senior programmer at c and c++, so that I must be having more experience than that. If you know more about wireless developing in c. please let me know what I have to do. Thanks in advance

(If this comment was disrespectful, please report it.)

 
10/26/2003 4:04:48 PMProgram-A-Bear

Thanks for the tutorial =). Ive been programming VB and PHP for a long time now, making 3D games and engines. I'm still pretty young tho, being only 15 ;) and my aim in life is to program games =P. I thought that if I want to make that then I should slowly leave VB as my main language and learn C++. Id no idea on anything about it but with this its starting to make sense :)





Thanks again mate ;)
(If this comment was disrespectful, please report it.)

 
11/12/2003 12:59:09 AM

this is cool havent done coding since BASIC 15 years ago good site
(If this comment was disrespectful, please report it.)

 
11/27/2003 2:33:17 AM

the program compiles but it wont stay open for me to see. i added the gretchar thingy and it gives me errors and wont compile then. what do i do???
(If this comment was disrespectful, please report it.)

 
12/4/2003 12:43:29 AM

nice site
(If this comment was disrespectful, please report it.)

 
12/27/2003 9:51:24 AM

My bloodshed's iostream.h seems to have something wrong with it. Whenever I compile anything calling it, bloodshed pulls it up and highlights the line #include "backward_warning.h"
(If this comment was disrespectful, please report it.)

 
1/1/2004 1:12:38 PM

Great tutorial to bad it blinks and then exits ive tried everthing ive got win xp and using dev c++ please help me thanks in advance
(If this comment was disrespectful, please report it.)

 
2/12/2004 3:15:44 PM

Just a tip - Make your own program from scratch and keep adding everything you learn. You can juice up the comments and keep it as a master reference. You learn best when you create your own code to solve problems. Plus libraries have books on this for free!!
(If this comment was disrespectful, please report it.)

 
3/2/2004 3:37:50 PMJosh *Acecool* M

5 stars, thanks.
(If this comment was disrespectful, please report it.)

 
3/5/2004 1:26:12 PM

hh
(If this comment was disrespectful, please report it.)

 
6/18/2004 12:06:43 AM

Thank you this is exactly what I need man!!!
(If this comment was disrespectful, please report it.)

 
7/19/2004 8:10:30 AM

I have seen & tested on my PC
its very nice and good for begineer
like us
(If this comment was disrespectful, please report it.)

 
7/19/2004 1:32:14 PM

great tutorial. where did you learn c++. please tell me.
nicknicknick3@hotmail.com
(If this comment was disrespectful, please report it.)

 
8/6/2004 1:15:28 AMLknsngth

How bout Endline???

cout << "blahblahblah";
cout << "adf";
is equivelent to
cout << "blahblahblahadf";
if you stick a endl (end-line)
then you "end the line"
so
cout << "a" << endl;
cout << "b" << endl;
comes out as:
a
b
not
ab

(If this comment was disrespectful, please report it.)

 
9/1/2004 2:32:13 PM

I checked ur basic display program (hello.cpp) it has problem with dev c++ that compiler error. please let me know as soon as possible
(If this comment was disrespectful, please report it.)

 
9/18/2004 3:37:48 AM

f
(If this comment was disrespectful, please report it.)

 
9/18/2004 3:40:49 AM

the only way i can see is to tell the program to repeat the answer over and over again here is an example

#include
int main()
{
int number1;
int number2;
cout<<"enter the first number"< cin>>number1;
cout<<"enter the second number"< cin>>number2;
while(10 == 10) cout<<"the answer is "<<(number1*number2)< return 0;
}

the program will add the two numbers together it took my the user and multiply them it should repeat the answer over and over again
(If this comment was disrespectful, please report it.)

 
10/1/2004 12:35:11 PMGerardo Diaz

is that it ? just 7 lines come on this is a very very very beginners tutorial if you can call it tutorial, I thinks it's helpless
(If this comment was disrespectful, please report it.)

 
10/24/2004 9:17:04 AM

Uhh, I think somethign happened to my compiler. :\ It was working but I forgot the d in include when typing it, so I had to do it over, and now the compiler just blinks the status and file thing. (Status: *blinking "compiling" File:*Blinking "Hello.cpp") I tried starting a new project and doing it from scratch and it still doesn't work. Does anyone know what happened?
(If this comment was disrespectful, please report it.)

 
2/26/2005 7:10:53 PM

This is the first thing i've ever learnt about programming, and it is so easy to understand, thanks
(If this comment was disrespectful, please report it.)

 
3/10/2005 7:18:46 AM

I'm a complete beginer at this and upon finding this tutorial thought that I'd at last found something simple enough to get me started,but I still managed to mess it up. So heres my very basic question~after executing something should happen,right?All I get is a grey box titled window app.
Very demoralising.
What is wrong?
(If this comment was disrespectful, please report it.)

 
3/26/2005 2:19:46 AM

please somebody help me..to make output like this using C plus plus
output:
A
BB
CCC
DDDD
.
..
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
(If this comment was disrespectful, please report it.)

 
5/6/2005 8:17:00 AM

awesome tutorial, you Xplain things well. i gave a 5
(If this comment was disrespectful, please report it.)

 
7/4/2005 12:47:53 PM

I was reading the comments and some people were saying they have problems compiling it, it may be your compiler, as i have noticed Dev-C++ doesnt like "general" C/C++ and has problems compiling with the includes with the .h and etc. i didnt read enough to see if anyone pointed this out but, i hope i helped someone
(If this comment was disrespectful, please report it.)

 
9/15/2005 11:30:56 PMel

Hi Jared,
can I test how good you are?
(you may not publish this)But I would like to get the programs. Thanks.
Exercise 1:
Write a program that simulates a scientific calculator:
This calculator performs the mathematical operations: ‘+’, ‘-’, ‘x’, ‘/’, ‘%’ and functions: ‘sin’, ‘cos’, ‘abs’.
Write this program two times, once with each selecting method.
(If this comment was disrespectful, please report it.)

 
11/4/2005 9:18:28 PMdaniel

This thing doesn't work for me. Im using Dev-C++ 4.9.9.0 .

I'v tried every thing. I did everything you told me to do in this tut, but still, it doesn't work.

This thing always show me some errors. And few times it workd, I opend the hello.exe, it pops up and closes.
(If this comment was disrespectful, please report it.)

 
12/19/2005 9:37:20 PMBrad

WOO this is the best tutorial i have seen.. Great Guy
(If this comment was disrespectful, please report it.)

 
1/16/2006 7:31:09 PMphraZe

Hey, theres a LITTLE important detail u forgot!

The STD stuff in your example.

If jared didnt read this, what you can do if this code doesnt work is putting the line:
using namespace std;
between the #include line and the int main() line
(If this comment was disrespectful, please report it.)

 
2/2/2006 6:26:53 PMfranky

i am a total begginer when it comes to this i understand what the symbols and why you have everything set up the way you do i have read it over and over to the point where i understand the code but i am now lost how do you get it from text file to something you may use to actually compile once created well anyways i appreciate your time that you took to the time to post such a thing for us that are looking for that extra help and knowledge even when some may not afford to anyways thanks for your time and consideration
(If this comment was disrespectful, please report it.)

 
6/3/2006 4:16:47 PMJon

hey jared ive tried all kinds of ways to get the program not to flicker but i still cant get it can u tell me the way to do it thanks
(If this comment was disrespectful, please report it.)

 
6/16/2006 10:31:16 PMJacques

Great tutorial for starting out. 5 Star! I just learned C++ about a month ago. I was wondering about remote file access. About James' question, try system("PAUSE"); Any one know where I can get Win32 Tutorials for beginners or maybe some good introduction books?
(If this comment was disrespectful, please report it.)

 
7/27/2006 8:18:49 PMZack

Great tutorial! The only part that I don't entirely understand is your explanation of line 6. Other than that, great job.
(If this comment was disrespectful, please report it.)

 
8/3/2006 5:15:49 PMHelix

wow, thanks, that clears up a lot! the one
thing that bugs me is u never sayed how to make the program (in windows) stay on the screen... did i miss somthing? mabey it is one of the other ones...
thanks for evey thing, it was a big help!
(If this comment was disrespectful, please report it.)

 
9/26/2006 7:04:54 PMBrent

Sorry guys. He wrote this tutorial YEARS ago I don't think he's still posting comments.

(If this comment was disrespectful, please report it.)

 
9/29/2006 12:08:25 PMRobert

One word for you on your tutorial..."FANTASTIC!!!!!!!" Any info on how to use VS .NET Pro for C++?
(If this comment was disrespectful, please report it.)

 
10/6/2006 6:27:48 AManthony

thanks..,nice! i rate you five! i learned a lot...,
(If this comment was disrespectful, please report it.)

 
10/14/2006 12:22:13 PMJohn

Thanks a lot for an excellent tutorial! This guide was one that really got started on my feet in C++ programming. I have a noob question though. I tried copying + pasting a program into Notepad, saved it as a .CPP file format, and opened it in Dev-C++. When I tried going to Execute > Compile, under the Complier tab it said "The system cannot find the file specified". Anyone know what is the problem? Thanks in advance for the help.

Once again, great tutorial, I recommend it for anyone who wants to start in C++ programming.
(If this comment was disrespectful, please report it.)

 
12/16/2006 2:53:06 AMRyan

I found this tutorial really helpful and he does a really good job of explaining what the script is doing. I gave it a 5!
(If this comment was disrespectful, please report it.)

 
2/12/2007 6:17:34 PMCody

OMFG this is one of the worst TTs i have ever seen, it only explains the Hello program, which is almost usless in the real world, it is lower than basic!!! you need to know this, but you also need to know about, if, else, and, int, bool, char, and espcaily the string dll. i am sorry, but if i were more noob than i am, i stil would of said it was bad. nice job with the discription, but if you attempted to include everything, it would be an instant 5 star. gave you a 1.
(If this comment was disrespectful, please report it.)

 
3/8/2007 3:12:50 AMmursalat

Thnx a lot for your help i really appreciate, it really helped me get started, you described everything nicel, thnx,i give you a 5*.
(If this comment was disrespectful, please report it.)

 
4/13/2007 3:03:07 PMDonkey

Wow! This is a great tutorial! I really learned of this.
thank you! keep up the good work! :)
(If this comment was disrespectful, please report it.)

 
11/12/2007 12:27:19 AMwinston

i thought that it was great. i have to agree with cody though you could have gave a bit more info about other things than the "hello world" file. but i still give it a 5 star. WAY TO GO!!! lol anyway hope you make more
(If this comment was disrespectful, please report it.)

 
2/27/2008 10:18:35 PMprabhu

so nice code and easily understand all, thanks to all sir
(If this comment was disrespectful, please report it.)

 
5/13/2008 8:02:35 PMSteeve

i need your email, how can i make Devc++ compiler stop compiling so fast, or at least let me see what i did... it does it too fast to even see a word.
(If this comment was disrespectful, please report it.)

 
10/30/2008 12:49:31 PMsms24

thanks for detail explanation i'm trying to learn c++ and reading from two different sources and reviewing on your tutorials is great trying to get as much understanding
(If this comment was disrespectful, please report it.)

 
1/2/2009 1:37:52 PMMichael

Jared, Thank you for taking the time to not only write this, but put it up for all to use, learn from & see. I have read, half way through, a couple of books about C++ programming, but you explained things they did not. I look foreward to the rest of the tutorial. Also, DevC++ is bad to the bone compared to what I've been using. Once I have a good handle on the basic's of C++, I will go back to useing a text editor & GNU, to get a handle on the training I've already started. Once again, Thank you. By the way, you can say you've taught an old dog a new trick, being that I'm in my forth decade of life.
(If this comment was disrespectful, please report it.)

 
2/1/2009 12:18:50 PMS

Jared,

When i run the program using DevC++, it flashes but when i add system("PAUSE"); i am able see the program.



(If this comment was disrespectful, please report it.)

 
5/4/2009 8:23:53 PMSammie

very detailed! m lovin it..thanks. P.S my first program.
(If this comment was disrespectful, please report it.)

 
7/1/2009 9:38:44 PMLuke

"On Windows Machines the application will close very quickly if you run it. THAT IS OKAY! We will learn how to fix that later.."

You said we will learn how to fix that later, but you never got back to it! How do I fix that??
(If this comment was disrespectful, please report it.)

 
7/6/2009 12:41:51 AMsuraj

this is the best of best tutorial.he clears my all douts.it is very simple and easy to understand.
(If this comment was disrespectful, please report it.)

 
11/10/2009 2:53:19 PMTorrment

i found the tutorial really easy to understand and thats the big word there understand wtg
(If this comment was disrespectful, please report it.)

 
5/24/2010 5:20:20 AMbiggiedanigga

how can i download the tutorial
(If this comment was disrespectful, please report it.)

 
3/18/2013 11:30:59 PMZohan

hey Jared
i'm also a beginner at this and basically using everything ive learned in a giant source file
anyway i just thought id comment and say
this is a good tutorial but i must make a few corrections if using dev c++

// tells the compiler to include the i/o stream
#include
// begins the main function
int main()
{
// tells compiler where to look if it cant find what cout and endl mean
using namespace std;
// outputs "hello world " on screen
cout << " hello world " << endl;
// helps in dev c++ pauses the system so you can see what the output is
system ("pause");
// exits the window
return 0;
}

thanks Zohan
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.