Results 1 to 4 of 4
  1. #1
    Mr. Bond's Avatar
    Join Date
    Mar 2008
    Gender
    female
    Posts
    14
    Reputation
    10
    Thanks
    2

    [C++]Hello World; Your first C++ Program

    Hello guys, thought I'd start off with a nice simple tutorial on making your first C++ Program. I'm only 14 so your probably better off to go Google a more detailed tutorial .

    I'm assuming you have a compiler at this time, if you don't then go and torrent Microsoft Visual Studio. Personally i use 2003 .Net because it best fits my needs, but any is good really.

    After you have a compiler open up a new Win32 Console Application and name it whatever you want.
    If you're using MSVS, when you start a new project in the settings select 'Empty Project' to stop any precompiled headers.

    Please Read: DON'T Just copy and paste! You WONT learn anything unless you retype it out later, type it out yourself. You will learn a hell of a lot more then just copy and pasting.

    Code:
    #include <iostream>
    
    using namespace std;
    Don't worry about this too much for now, but iostream and std contains some basic functions that we're going to be using.

    Next Add~
    Code:
    int main()
    {
    }
    int main() is the what our program will execute(use) when you run it.
    int stands for integer which means that we're going to have to return a value in main() else we will get compile errors!
    "{" and "}" are the opening and closing brackets for "main()", { is where main() starts and } is where main() ends.
    These aren't just for main() though! You can use these for any of your own voids/integers/methods that you create, for instance
    "void myVoid() { }"
    Here the brackets do exactly the same thing, anyway, moving on~

    Add the rest of the code into your main() integer.
    { Remember to add the code in between the brackets }
    Code:
    cout << "Hello World!" << endl;
    cin.get();
    return 0;
    cout stands for "console output" and is used to output data onto a console (The black box looking thing).
    Anything after the operator "cout <<" is outputted onto the console, because we're outputting a string we will use speech marks.
    The full code "cout << "Hello World!" << endl;"
    outputs 'Hello World!' and endl means end line so it goes to the next line.

    cin.get() basically 'pauses' the programming until you press a key, stopping our program from just flashing open and close;

    "return 0;" Remember what i said earlier about main() being an integer and needs to return a value, well this just returns the value 0.

    Now the code should look like this:
    Code:
    #include <iostream>
    
    using namespace std;
    int main()
    {
      cout << "Hello World!" << endl;
      cin.get();
      return 0;
    }
    Notes
    We use ";" to declare the end of a line, you can also however use it to seperate different things and put your code on one line like this:
    Code:
    cin << "Hello World!" << endl; cin.get(); return 0;
    I don't want to go into too much detail about cin, it stands for "console input", try googling it .

    Ending Program
    Now we are finished, this is what our program should do on a console screen:
    Code:
    Hello World!
    ~Mr. Bond

    P.S. If there are any errors in this tutorial please contact me immediately
    Last edited by Mr. Bond; 03-15-2008 at 01:38 PM.

  2. The Following 2 Users Say Thank You to Mr. Bond For This Useful Post:

    cacho232 (10-16-2008),kaneo93 (01-11-2009)

  3. #2
    kaneo93's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    2
    sheeewwwwweeeeeeettttt

  4. #3
    NatureSkillz's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Location
    In This Thread
    Posts
    652
    Reputation
    17
    Thanks
    222
    My Mood
    Yeehaw
    Thanx mate, i need downloadl ink, plz get it for me. of u can, thanx!!!
    Great Sig From TryMe, And Resized by bugmenot

    Click here to feed me a Nude Girl!!
    How To Create A MapleStory Private Server, Odin Based, And
    Fully Updated Aswel!:

    Click Here For A New MapleStory TUT V55

    Ever wanted to Spam/Troll/Flame without getting banned?<Free for Everyone!?!?>


    People I Respect;
    *- Natureskillz
    Contact me if you want to be on the Respect list, You must do something good against me, or have a good reason >.>

    +1 Post Count!

  5. #4
    cyberghost's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    somewhere, world
    Posts
    14
    Reputation
    10
    Thanks
    5
    Hey thanks for the tut it worked for me> i am using relo2 to compile , build and run with a borland c++ add-on compiler. really appreciate ur good tut and look foward to seeing more. Thanks!!!!!!!!!!

Similar Threads

  1. Replies: 13
    Last Post: 12-28-2009, 01:13 AM
  2. *DLL* [Tutorial] Make Your first DLL Interacted to a Form Project...
    By Silk[H4x] in forum Visual Basic Programming
    Replies: 14
    Last Post: 06-26-2009, 08:52 PM
  3. Replies: 28
    Last Post: 03-02-2009, 07:44 AM
  4. Your first Hack
    By merkado in forum Visual Basic Programming
    Replies: 6
    Last Post: 07-09-2008, 05:15 PM
  5. [Tutorial] Your first program
    By akimoko in forum C++/C Programming
    Replies: 10
    Last Post: 06-23-2007, 12:58 PM

Tags for this Thread