C++ Guide menu

Shout-Out

User Tag List

Thread: C++ Guide

Results 1 to 7 of 7
  1. #1
    Despara's Avatar Member
    Reputation
    12
    Join Date
    Apr 2008
    Posts
    118
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C++ Guide

    Getting Started:

    By the end of this tutorial you would have learnt how to output text,

    Intro:
    I've always been sort of dissapointed with RaGEZONE's Coders section. It's always been full of VB-wh0res and web developers (although, WDs aren't bad). I've always wanted RaGEZONE's coders section to become more Desktop-programming orientated (Not inc VB). Although I think only 5-10% of this section consists of this.
    So I'm here to provide people with a series of C++ tutorials (How many, is depending on the comments I recive: Good/Bad).
    So here's Lesson #1:

    The first you're going to need to begin your C++ adventure is a descent compiler. There are many compilers about... some of which, barely pass as a compiler.

    Although there are many C/C++ compilers about, there are two in mind that are considered the best (better userability/more user-friendly, better compiler and better debugger).
    Personally I'd say Microsoft's Visual C++ Compiler and IDE has a better debugger, I feel Bloodshed's Dev-C++ IDE and Compiler is more user-friendly, and easier to navigate.
    But don't take my word for it, try it out for yourself:


    (Windows Compatible)
    Microsoft Visual C++:
    Overview: Download details: Visual C++ 2005 Redistributable Package (x86)
    Download: http://www.microsoft.com/downloads/i...redist_x86.exe

    (Windows Compatible) (Reccomended)
    Bloodshed's Dev-C++:
    Overview: Bloodshed Software - Dev-C++
    Download: SourceForge.net: Downloading ...

    Other: (Reccomended by Daevius)
    Code :: Blocks:
    Download: SourceForge.net: Downloading ...

    Okay, so I'm going to be writing a tutorial as if you were using Dev-C++ v5.0, although if you have any other version of Dev-C++ or even a different compiler, the simple things like Compile and Run are pretty much simple.

    So, lesson #1 is going to be teaching you how to compile your first program, and explaining data types.
    So I'm going to need you to install the provided downloads given to you, install the programs and then double click the exe to launch the program.
    So after you have launched the program, you're going to want to create a console application (the next few tutorials we will be using console application).
    So go to File > New > Project... and then select Console Application, and name it 'MyProject' or anything you want (It's just a name), but it's best to keep a directory, for easy access and organisation. Once you've given a name to your project, make sure that 'C++ Project' is selected. Once you have done all of this, click 'Ok'.

    Now, you should have a window with the following code in it:

    Code:
    #include <cstdlib>#include <iostream>using namespace std;int main(int argc, char *argv[]){ system("PAUSE"); return EXIT_SUCCESS;}

    ...or some similar code.

    What I want you to do is highlight it all and delete, so your project is left empty.

    Okay, so after that's done, I want you to take a look at this code:

    Code:
    #include <iostream>using namespace std; int main(){cout << "Hello There RaGEZONE\n"; // Outputs the sentence "Hello There RaGEZONE") cin.get(); // Requests user to hit Enter key to end application }
    Anything familiar about the above code? If not, no worries at all This is the reason I'm here, to teach you what this means and how to use it

    That's start with #include <iostream>.
    #include <iostream> is something called a preprocessor directive that requests code from that header file to put into our application.
    By including a header file, it provides you with the use of certain functions, such as cout.


    The next line of code is: using namespace std;
    using namespace std; is similar to that of <iostream>. Basically, this line of code is something called a standard library. Using this line, it allows you to use certain functions such as cout. (See the similarities?). Also, notice the semi-colon ( ; ) on the end of the the line of code. This is apart of C++'s syntax and is used for most commands.



    Now the next line is int main ().
    This is the beginning of the main functions. It's where the C++ program's start their execution (depending on the location of the code).
    int is for when the fuction returns an integer.
    The braces ( { } ) bascially defines the beginning and the end of the execution.
    Everything after { is what will be executed, everything before } is what has been executed.

    Note: When I say "Executed" it basically means performed/done/run.


    cout << "Hello There RaGEZONE\n";
    Now what this is doing is outputting the phrase "Hello There RaGEZONE"
    Think of the statement cout as output.
    cout is declared in the iostream standard file within the std namespace, this is the reason why we needed to include that specific file and to declare that we were going to use this specific namespace earlier in our code. (Every line of code is done for a reason). The bracket things << are insertion indicators, indicating what our output is going to be.
    The \n means newline. What it does is seperate output on the screen, so it doesn't look disorganised:
    Example:

    Code:
    cout << "Hello Ragezone";cout << "I'm Awesome";
    This would output as:

    Quote:
    Originally Posted by Output
    Hello RagezoneI'm Awesome

    Now, if you wanted a space between Ragezone and I'm, you would have to make sure you left a space in one of them:

    Code:
    cout << "Hello Ragezone ";cout << "I'm Awesome";
    or

    Code:
    cout << "Hello Ragezone";cout << " I'm Awesome";
    Or if you wanted it to be one line of code:

    Code:
    cout << "Hello Ragezone\nI'm awesome";
    Output:

    Quote:
    Originally Posted by Output
    Hello Ragezone I'm awesome

    Note: Notice how the \n (newline) is ALWAYS within the double quotation marks? This is a Must!

    Note: C++ is a case-sensitive language, so everything has to be the way it's supposed to be:
    Cout = wrong
    cout = right

    //
    This is simply to mark line notes. They don't affect the application in anyway, they're only used for viewers of the code.
    /* this is
    a
    blocknote*/
    A blocknote is a... well, a note formatted as a block. This is used for full, descriptive explenations of a piece of code.

    cin.get();
    (Notice the ; ? It's been used throughout this application, remember what I said? It's used on functions).
    Without placing the cin.get(); , the application window will instantaneously open and close. By placing cin.get(); at the end (before the end bracket), it means the application needs the user to press enter for the application to close.

    After you have typed all of this code in, and know what everything is, try mesing about with the code a bit. Insert \n with new phrases. Learning C++ is all about exploring. I'm going to give you a guideline but you will have to explore solo a bit if you want to fully understand C++'s nature

    And for the end part:
    After you are happy with your codes, go to Execute > Compile & Run name it to whatever you want and there you have it! Your first C++ application.
    This is the end of C++ Tutorial #1
    I will be writing C++ Tutorial #2 Soon

    What will be in Tutorial #2?:
    You will be learning about data types, becoming more familiar with console applications and functions within. I will teach you how to use declare and define, how to manipulate integers and will result in teaching you on how to make a calculator

    C++ Guide
  2. #2
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code tags ftw?

  3. #3
    blackfang500's Avatar Member
    Reputation
    35
    Join Date
    Apr 2007
    Posts
    491
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Epic fail. Notice that he said "Hello ragezone" I'm fairly sure I saw this guide before, copy+pasted.

  4. #4
    inzenir's Avatar Member
    Reputation
    9
    Join Date
    Aug 2009
    Posts
    52
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, it's kinda fail.... If nothing else using namespace std; sets default input and output to standard, that's keyboard. It isn't ment to allow you usage of count or cin, it's ment for this:

    Code:
    #include <iostream>
    
    int main()
    {
        cout << "Hello world";
        return 0;
    }
    this code will give you an error, why? compiler doesn't know where to output.
    To fix it, you have to do this:

    Code:
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello world";
        return 0;
    }
    or

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        cout << "Hello world";
        return 0;
    }

  5. #5
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by inzenir View Post
    Well, it's kinda fail.... If nothing else using namespace std; sets default input and output to standard, that's keyboard. It isn't ment to allow you usage of count or cin, it's ment for this:
    Rofl. You have zero idea what you're talking about. Either that or your english is so awful I'm misunderstanding what you're saying.

    At any rate I think you need to familiarize yourself with what a namespace is and what it's used for...
    Last edited by Cypher; 09-23-2009 at 06:56 AM.

  6. #6
    insignia96's Avatar Banned
    Reputation
    33
    Join Date
    Oct 2008
    Posts
    304
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Imma gonna say this is C&P'd shit.

    Couldnt find a link but omfg give some credits.



  7. #7
    shdgf11's Avatar Member
    Reputation
    1
    Join Date
    Dec 2008
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Last edited by shdgf11; 09-20-2009 at 11:38 AM. Reason: Added er link more.

Similar Threads

  1. 1-60 Horde Leveling Guide w/ Quests
    By Matt in forum World of Warcraft Guides
    Replies: 23
    Last Post: 04-17-2007, 07:26 PM
  2. Blackwing Lair: Ultimate Boss Guide
    By Matt in forum World of Warcraft Guides
    Replies: 11
    Last Post: 11-02-2006, 05:18 AM
  3. 8 World of Warcraft Guide Packs (Gold, Profs and Skills)
    By Matt in forum World of Warcraft Guides
    Replies: 17
    Last Post: 09-23-2006, 10:53 AM
  4. Guide: Gold (Dupe 01)
    By janzi9 in forum World of Warcraft Guides
    Replies: 13
    Last Post: 09-18-2006, 09:02 PM
  5. Accelerated Leveling Guide 48-60
    By Matt in forum World of Warcraft Guides
    Replies: 0
    Last Post: 03-03-2006, 11:49 PM
All times are GMT -5. The time now is 01:46 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search