[C++] My First Code! Hello World!

Newbie Spellweaver
Joined
Dec 4, 2007
Messages
14
Reaction score
0
NEW QUESTION! HOW DO I EXPORT MY Application

I just made my first console war text based game. This is the first version and is done. So how do I make it into a file that I can host at rapidshare and have people download? Or how can I host it on a free website where people can just go there to play it?

I'm sure its pretty hard but I just spent 5 hours coding this game from scratch and I am drop dead tired. I ended up cutting out about half the game just so I can get it done. I now 100% know IF STATEMENTS... yaya for me =(. Thanks for anyone willing to give me the low-down/ a tut to host my game so other can play it.

I'm not 100% sure what all I have to include in the file to make it easier for a person to run (I.E. click on icon and game starts)


















Well I have wanted to learn how to make an mmorpg for a long time. I played the game "Runescape" for awhile and I think it would be amazing to have my own mmorpg like it. I know it will probably never happen but I would still like to learn the basics of coding and maybe down the road attempt a rpg. Anyways, I am starting the beginner tutorials and just finished my first one. It was fun, interesting, and laid out in a very easy to understand manner. The tutorial taught us to make a "Hello World" program which is basically just the command box popping up and saying a sentence you programmed it to.

Some of the things I changed in the code;
1) You can now press any key and the program will terminate (not just the enter key)
2) I changed the text and entered several line breaks
3) I added a block note!

My Code
#include <iostream>
using namespace std; int main()
/*Here are some directions and descriptions its called a block note*/
{cout << "Ohh brave new world!\nWith Such People In It\n\n\n\nYou Idiot ";system("PAUSE");}

So like I said there is my very basic code and I just had to share my accomplishments. I also have a few questions;
1) What does the code #include <iostream> do? Is it just a basic opening code that is necessary for your program to execute?

2) What does the code using namespace std; do? Is it just a basic opening code that is necessary for your program to execute?

Thanks for all the help!
I'm sure its pretty technical to do and has a lot of parts I just spent like 5 hours coding this game and I am drop dead tired so if anyone helps me I will be suprised/ incredibly greatful
 
Last edited:
#include <iostream>
includes the library

using namespace std;
you dont have to use it
but then you have to type
std;;cout instead of cout
and std;;cin instead of cin
less typing^^

u can use "endl" to end lines 2:P

Code:
cout << "Hello World" << endl;
cout << "Hello Again" << endl;
 
or just
cout << "Hello World," << " Hello Again\n";

Which would output as:

Hello World, Hello Again


If something looks dodgy up there, probs is. Haven't done anything in months.
 
A bit more detail.

iostream is your basic Input/Output (IO) stream library. This allows you to use input (cin) and output (cout). So that is why you need to include the iostream library. If you were not going to use input/output you neednt include it at all.

Using a namespace is specifiying that a certain namespace (in this case std) should be normally recognized. In other words, as shadow-xx said it allows you to not have to type std::cin/std::cout/std::endl the whole time. A word of caution to remember though is that using namespace's can conflict and overlap. Causing unexpected errors. So always be carefull when using namespace's. As a general rule I tell my students to never to use namespace's but it is acceptable usage as long as you keep track of what your including.
 
Good that you started with C++ ;)

So like I said there is my very basic code and I just had to share my accomplishments. I also have a few questions;
1) What does the code #include <iostream> do? Is it just a basic opening code that is necessary for your program to execute?

2) What does the code using namespace std; do? Is it just a basic opening code that is necessary for your program to execute?

Thanks for all the help!

As Keldarn said, the include function includes headers/libraries. These libraries contain functions and classes (std is a class) that control your CPU to output the result you want.

And by using the namespace you set the default class to std. Else you would have to use std::cout << "blahblah" << endl; instead of cout << "blahblah" << endl;

The endl command, for extra clarity, outputs a character to indicate the end of the line (so the text you output after endl will be on a new line). This character is different on the Windows/Mac/Linux.

Windows: \r\n
Linux: \n
Mac: \r

endl (last character is an L (endline)) outputs the right end-of-line character, depending on what OS you run ;).

Good luck, make a console war game like many people do ^^,
 
Thanks everyone for the support. I'm going to do some more tuts tonight.

Daevius, I am planning on making a console war game like asteroids or something similar. Any good basic tutorials for a console game like that? Or should I keep doing the very basic hello world and beyond tutorials? Anyone know of any good beginner tutorials also?
 
3dbuzz have some good tuturials

* pm me if u want them not alouwd to post any iligal links here *

and i saw a few on youtube^^

there is some stuff about c++ in the seccond sticky
 
I thought console war games games like the one you just got finished making shadow xx the one in the showcase area that is like asteroids. I just finished my first text based console game which was fun for awhile but kind of boring. I really want to start getting into graphic games. By "graphic games" Im talking about pong or something like that... not a text based game. Any help anyone?
 
NEW QUESTION! HOW DO I EXPORT MY Application

I just made my first console war text based game. This is the first version and is done. So how do I make it into a file that I can host at rapidshare and have people download? Or how can I host it on a free website where people can just go there to play it?

I'm sure its pretty hard but I just spent 5 hours coding this game from scratch and I am drop dead tired. I ended up cutting out about half the game just so I can get it done. I now 100% know IF STATEMENTS... yaya for me =(. Thanks for anyone willing to give me the low-down/ a tut to host my game so other can play it.

I'm not 100% sure what all I have to include in the file to make it easier for a person to run (I.E. click on icon and game starts)


Ya so far I feel completely comfortable with IF statements. I kind of took a break to code my own Console War. FFS it takes a long time. I have about 80 freaking IF statements. I think I went overboard but I do want to finish it =p
 
Last edited:
How did you test your game? What IDE do you use?

Generally executables are saved in the bin directory of your project...
 
Back