| Lesson Part II (C++); lesson 2 (your first program) | |
|---|---|
| Tweet Topic Started: Aug 13 2006, 10:06 PM (537 Views) | |
| fsd | Aug 13 2006, 10:06 PM Post #1 |
|
3a4
![]()
|
Ok lets make your first program in c++ type in the following (or copy and paste it)
ok now let me enplane it #include <iostream> - This is a C++ library. C++ has library for about what ever you can think of and this one is for I/O (input and output) this is used because cout (Think of C out) is how we output things to the screen also cin (Think of C in) it how we allow people to input but im not going over that right now. using namespace std; - Dont worry about this. This makes all your commands have the namespace std. Namespaces can be useful but not so useful when starting out. If you did not have this you would need to put std: in front of everything. int main () - all you need to know now is that this starts your program. void main() is sometimes seen in old c++ programs but it will not work anymore with most compilers and was never a part of standard c++. cout << "hello world\n"l; - cout (as i said earlier) is the output command and << is for output and >> is for input. You put what you want to output in double quotes. The \n is for a new line and you have to end everything with a ; system("pause"); - your not on a ms dos (i hope you aren't) so when windows goes through everything in the program it closes so if you put system pause it pauses the system and will not auto close return 0; - well int main returns a integer so this is how we do that If YOUR CONFUSED ABOUT THAT JUST MOVE ON You might say that you have seen people use endl and that also goes to a new line. But i like \n better because it uses less system system resources. (It flushes the output buffer). Although it probably wont make a difference in a small to medium program. Here is what that line looks like with endl (it is end l not end one. The l stands for line) cout << "hello world" << endl; and there we go you did your first c++ program. Fixed Title --ari_aaron edited it and made it better - fsd |
|
"mmmmm i love the internet. every time i go to a website i get a cookie HOW AWESOME IS THAT!" - Quote from me "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - Albert Einstein "Imagination is more important than knowledge."- Albert Einstein | |
![]() |
|
| ari_aaron | Aug 14 2006, 08:04 AM Post #2 |
|
1a4
![]()
|
Very good work! I just want to point out that instead of
You could have done
I'm pretty sure that that would work too, although I haven't tried C++ in a while (becuase I know VERY little of it). |
|
My msn: ![]() ![]() If anyone wants GMail or Windows Live Messenger invites, PM me! | |
![]() |
|
| tomster 785 | Aug 14 2006, 09:54 AM Post #3 |
|
3
![]()
|
my frst C++ program was a fareheit to celsius converter then I made a little ball that bounces around the screen and so on I learn most things through trial and error but I learnt that through a tutorial |
|
<if you like peanut butter put this in your sig> <if your the man with the plan put this in your sig> <if you've ever won a graphics battle put this in your sig> please join these forums: the GMC?|Graphics forums|my forum|the scary|the spriters network|middle ground forums|pixel|pixeltendo|retro-ness (1-up)|SMP(screaming metroid productions I have joined alot of forums haven't I? | |
![]() |
|
| fsd | Aug 14 2006, 10:13 AM Post #4 |
|
3a4
![]()
|
my second program ever (with c++) was feet to inches then i made miles to feet |
|
"mmmmm i love the internet. every time i go to a website i get a cookie HOW AWESOME IS THAT!" - Quote from me "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - Albert Einstein "Imagination is more important than knowledge."- Albert Einstein | |
![]() |
|
| tomster 785 | Aug 14 2006, 10:45 AM Post #5 |
|
3
![]()
|
I you get a good feeling inside when you make your first program using C++ |
|
<if you like peanut butter put this in your sig> <if your the man with the plan put this in your sig> <if you've ever won a graphics battle put this in your sig> please join these forums: the GMC?|Graphics forums|my forum|the scary|the spriters network|middle ground forums|pixel|pixeltendo|retro-ness (1-up)|SMP(screaming metroid productions I have joined alot of forums haven't I? | |
![]() |
|
| fsd | Feb 7 2007, 06:09 PM Post #6 |
|
3a4
![]()
|
ok i know my c++ tutorials are not that great so i edited this one i may edit the others if you want to see what is changed then go here http://www.firesoulsdomain.com/old_tutorial1.html |
|
"mmmmm i love the internet. every time i go to a website i get a cookie HOW AWESOME IS THAT!" - Quote from me "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - Albert Einstein "Imagination is more important than knowledge."- Albert Einstein | |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Tutorials · Next Topic » |











3:20 AM Jul 11