[N00b tips] C++ guide menu

These ads disappear when you log in.

Results 1 to 7 of 7
  1. #1
    EviNion's Avatar Sergeant
    Reputation
    9
    Join Date
    Jul 2008
    Posts
    57
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)

    [N00b tips] 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&C Would be greatly appreciateed

    Sincerely EviNion

    These ads disappear when you log in.

  2. #2
    arigity's Avatar Banned
    Reputation
    49
    Join Date
    Dec 2007
    Posts
    548
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    should use moar whitespace on your code as this ->> #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 } looks really mashed and can have misleading comments.

    |
    v

    #include <iostream>
    using namespace std;
    int main()
    {
    cout << "Hello There RaGEZONE\n";
    // outputs the sentence "hello There RaGEZEONE")
    cin.get(); // Requests user to hit Enter key to end application
    }

    all in all a nice guide though.

  3. #3
    EviNion's Avatar Sergeant
    Reputation
    9
    Join Date
    Jul 2008
    Posts
    57
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    ahh okay, thanks

  4. #4
    mager1794's Avatar Lieutenant Commander
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    this is a repost its on mmowned on one of the last few pages in the guide section
    Lunar Gaming - Reaching For The Stars

  5. #5
    **Sweeny**'s Avatar Knight-Lieutenant
    Reputation
    33
    Join Date
    Dec 2007
    Posts
    282
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    What will be in Tutorial #2?:
    The next page of the c++ tutorial website?? This is just using simple 5 lined scripts...

  6. #6
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Looks like more of a copy/paste master than C++

  7. #7
    EviNion's Avatar Sergeant
    Reputation
    9
    Join Date
    Jul 2008
    Posts
    57
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Sad Face, you caught me:P

    But I forgot to add

    Guide: ' the maker's name'

    So I am sorry =(

    forgiveness pl0x6):

    Thanks EviNion
    "Although I May Be Wrong Here, I am Never Far From Right" - EviNion

Similar Threads

  1. [n00b Tips] How to make your server public without hamachi
    By EviNion in forum WoW EMU Guides & Tutorials
    Replies: 5
    Last Post: 10-29-2008, 09:07 PM
  2. [n00b tips] how to make a zoo guide
    By EviNion in forum WoW EMU Guides & Tutorials
    Replies: 8
    Last Post: 07-26-2008, 01:07 PM
  3. [N00b Tips] How to perma spawn objects
    By EviNion in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 07-14-2008, 01:56 PM
  4. [Tip/Exploit/Guide] First in Damage (AV)
    By Ferag in forum World of Warcraft Guides
    Replies: 10
    Last Post: 02-03-2008, 06:46 PM
  5. Auction House Tips, Tricks Guide
    By Bossman4 in forum World of Warcraft Guides
    Replies: 1
    Last Post: 06-03-2006, 03:44 AM
All times are GMT -5. The time now is 11:09 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved. Digital Point modules: Sphinx-based search