C++ Part 1
4 posters
CMPC :: Computing :: Programming :: C++
Page 1 of 1
C++ Part 1
Ok so heres my super simple C++ tutorial for beginners!
Part 1: "Hello World!"
Traditionally a programmers first program is called the "Hello World!" program. Simply put, it prints the above words (or anything else you want, I don't care) to the screen.
Here are the things you will need:
A compiler - http://www.microsoft.com/express/Downloads/#2008-Visual-CPP (Windows only, Allen can suggest something for a mac)
NOTHING ELSE! Well sort of, that above download is sort of an all in one, sometimes you need other things.
So yea just go and install that. Afterward you will need to setup a new project, for now I suggest you select the option "empty project" If all goes well you should be looking at a blank project.
So here's what I'm going to do: Compilers ignore everything after "//" (without quotes) so I'm going to use that to comment below.
1. Without this you would need to type "std::cout" and "std::cin" every time. It isn't best practice but for now I'll be using it.
2. The "int" in this means it is waiting for a number to be returned before it ends. This can be substituted with different things such as "void" which ends the program after the last command. Also, everything in the brackets belongs to "main".
3. This gives the program the number it wants before it ends. 0 means it worked correctly, 1 or other numbers means it failed.
Homework:
1. Copy and paste my program, then select compile, then run.
2. Get it to say something else.
3. See what happens when you remove "cin.get();"
I'll be happy to answer any questions, it can be difficult for those just starting off.
Part 1: "Hello World!"
Traditionally a programmers first program is called the "Hello World!" program. Simply put, it prints the above words (or anything else you want, I don't care) to the screen.
Here are the things you will need:
A compiler - http://www.microsoft.com/express/Downloads/#2008-Visual-CPP (Windows only, Allen can suggest something for a mac)
NOTHING ELSE! Well sort of, that above download is sort of an all in one, sometimes you need other things.
So yea just go and install that. Afterward you will need to setup a new project, for now I suggest you select the option "empty project" If all goes well you should be looking at a blank project.
So here's what I'm going to do: Compilers ignore everything after "//" (without quotes) so I'm going to use that to comment below.
- Code:
#include <iostream> //required to input and output text
using namespace std; //a shortcut, see #1
int main() //Where your program begins, see #2
{
cout << "Hello World!"; //prints the words to the screen
cin.get(); //waits for you to press enter
return 0; // see #3
}
1. Without this you would need to type "std::cout" and "std::cin" every time. It isn't best practice but for now I'll be using it.
2. The "int" in this means it is waiting for a number to be returned before it ends. This can be substituted with different things such as "void" which ends the program after the last command. Also, everything in the brackets belongs to "main".
3. This gives the program the number it wants before it ends. 0 means it worked correctly, 1 or other numbers means it failed.
Homework:
1. Copy and paste my program, then select compile, then run.
2. Get it to say something else.
3. See what happens when you remove "cin.get();"
I'll be happy to answer any questions, it can be difficult for those just starting off.
Unchained- Mod
- Posts : 448
Re: C++ Part 1
I don't see why the hundreds of thousands of C++ tutorials on the internet could not be understood by Annie, but this could. You see where I'm going with this?
Admin- Pirate King
- Posts : 559
Re: C++ Part 1
Yea but its more like talking with this because they can ask questions and such.
Unchained- Mod
- Posts : 448
Re: C++ Part 1
dreamincode.net and cprogramming.com has forums..... JUST LIKE THIS ONE. except with a few thousand more users.
Admin- Pirate King
- Posts : 559
Re: C++ Part 1
Yea but it doesn't help that they are all Indian and the ones who aren't are dicks.
Unchained- Mod
- Posts : 448
Re: C++ Part 1
lol i hate the dickheads. they're the worst. fucking 30 stars under their avatar and they just redirect you to the tutorial.
Admin- Pirate King
- Posts : 559
Re: C++ Part 1
Ok, so Mel has my laptop (Windows) and I'm stuck on my mac and I'm totally lost with the XCode shit... yea..
Batguano- Ninja
- Posts : 101
Re: C++ Part 1
this is just ONE reason why macs suck. but another_pd has experience with xcode. ask him about it.
Admin- Pirate King
- Posts : 559
Re: C++ Part 1
I like my mac but like... I prefer my windows for programming stuff.. I tried this on my window and it worked fine
but like... yeaaaaa
but like... yeaaaaa
Batguano- Ninja
- Posts : 101
Re: C++ Part 1
Annie wrote:I like my mac but like... I prefer my windows for programming stuff.. I tried this on my window and it worked fine
but like... yeaaaaa
Admin- Pirate King
- Posts : 559
Re: C++ Part 1
What is the problem with Xcode?
What doesn't work? / What can't you figure out?
What doesn't work? / What can't you figure out?
Paul- Pickaxe
- Posts : 611
Re: C++ Part 1
another_pd wrote:What is the problem with Xcode?
What doesn't work? / What can't you figure out?
anything >_< I'm just gonna use my windows... it actually works better than xcode i think xD
Batguano- Ninja
- Posts : 101
Re: C++ Part 1
Well, did it install?
Did you find the application?
If so, what happened when you started the application?
Did you find the application?
If so, what happened when you started the application?
Last edited by another_pd on Tue Jan 26, 2010 4:58 am; edited 1 time in total
Paul- Pickaxe
- Posts : 611
Re: C++ Part 1
Is the image supposed to be just the upper sliver of your screen?
Paul- Pickaxe
- Posts : 611
Re: C++ Part 1
yuhp
now to try it on my windows once these files finish downloading <___<
now to try it on my windows once these files finish downloading <___<
Batguano- Ninja
- Posts : 101
CMPC :: Computing :: Programming :: C++
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|