[Guide] C++ Scripting/Programming Tutorial #1 menu

User Tag List

Results 1 to 9 of 9
  1. #1
    CoolManBob's Avatar Active Member
    Reputation
    92
    Join Date
    Jul 2006
    Posts
    208
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Guide] C++ Scripting/Programming Tutorial #1

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    cout << "Hello World!\n";
    return 0;
    }
    This is your basic Hello World Program.
    This is usually the very first program people start out with when they begin doing

    programming.

    Im going to explain what each line does

    Code:
    #include <iostream>
    # is a preproccessor operator, you may have used it with #define, a preprocessor operator

    tells the compiler to do something before it starts compiling, in this case it tells the

    compiler to find iostream.h and include it in this .cpp file.

    the <> tells the compiler that the file is a library file and to find the header or .h file

    in it's library folder

    When a compiler includes something, it means that the .cpp file can use functions that the

    .h file declares.

    Code:
    using namespace std;
    In programming there are things called Classes and namespaces, classes and namespaces are

    similar to each other in that they both are a group of functions, but they are different.

    Namespaces are a group of function identifiers, in this case std, this line tells the

    compiler that the .cpp file is using the std namespace so every time a function has a std

    identifier there is no need to use it, in this case cout is actually std::cout, but becuase

    we are using the std namespace there is no need to "identify" cout with std.

    Code:
    int main()
    This is the main function that is called when the program runs, this is absolutly important

    you have this, the program WILL NOT work if you don't have this function.

    the int before the main() is what must be returned when the function ends, in this case an

    int which means an integer, there are other things im sure you have seen, void, uint32, and

    others.

    void basically means that the functions will return no value, uint32 means the function will

    return a value of an uint32, exactly what a uint32 and other datatypes will be explained in

    another tutorial.

    Code:
    {
    This is an opening brace, it "opens" the function so code can be written in it and be

    executed.

    Code:
    cout << "Hello World\n";
    cout is a function that enables us to write to screen, there are other functions that can do

    the same thing, but for the sake of this tutorial and simplicity I chose to use cout.

    the << is an output operator, everything afer is is written to the cout function, so the

    cout function can output the text to screen.

    the quotations signify a string, what exactly a string is will be expalined in another

    tutorial.

    the \n is simply called an escape character, this certain one writes a new line, so if i

    were to add more text it would be written on the line after Hello World!

    Code:
    return 0;
    this piece of code tells the compiler to return a 0(zero) to the function. telling that the

    function ran fine with no errors.

    Code:
    }
    this is a closing brace, this "closes" the function so any code in the codeblock after this

    will not be apart of the function!

    Code:
    ;
    this is required after most lines of code, this ends the line of code, certain things do not

    need this, like an if, for, and others

    If you have any questions please don't hesitate to ask!

    There will be more tutorials!!!!

    Created by: CoolManBob

    [Guide] C++ Scripting/Programming Tutorial #1
  2. #2
    Vindicated's Avatar Contributor
    Reputation
    226
    Join Date
    Aug 2008
    Posts
    1,067
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This guy definatly knows what he's talking about. Look for more from this handsome young man

    Would give rep CMB but gotta spread


  3. #3
    Link_S's Avatar Member
    Reputation
    125
    Join Date
    Dec 2008
    Posts
    293
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by CoolManBob View Post
    the \n is simply called an escape character, this certain one writes a new line, so if i
    were to add more text it would be written on the line after Hello World!
    Wouldn't it be alot easier to understand for a beginner by using the endline function?

    cout << "Like this." << endl << "Beginning a new line" << endl;


    Great toturial, it's hard to explain code syntax; +Rep for you

  4. #4
    CoolManBob's Avatar Active Member
    Reputation
    92
    Join Date
    Jul 2006
    Posts
    208
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Link_S View Post
    Wouldn't it be alot easier to understand for a beginner by using the endline function?

    cout << "Like this." << endl << "Beginning a new line" << endl;


    Great toturial, it's hard to explain code syntax; +Rep for you
    I guess, but i have always perfered escape characters myself, so that is why i used one instead of using endl

  5. #5
    svedin's Avatar Contributor
    Reputation
    124
    Join Date
    Jun 2008
    Posts
    557
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really nice, i maby will test to script in C++

    +Rep to this guide

    **Edit**
    Will Rep you after 24H, i need to stop to give ppl rep so often

  6. #6
    trimm's Avatar Active Member
    Reputation
    27
    Join Date
    Aug 2008
    Posts
    76
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice guide, +Rep when it's off cooldown. Do you plan to write more guides?
    C++ is a loaded machine gun pointed at your feet with the safety off.

  7. #7
    Barnzy's Avatar Member
    Reputation
    67
    Join Date
    Jun 2008
    Posts
    302
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simple, try code what I code (hacks for multiplayer cheats for cod series)

    a much simpler hello world imo is

    #include <iostream>

    using namespace std;

    int main(int nNumberofArgs, char* pszArgs[])

    {
    cout << "Hello World" << endl;
    system("PAUSE");
    return 0;
    }


    instead of /n just endl (end line)

  8. #8
    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)
    system("Pause"); bad idea, avoid that. THere are numerous reasons just google "system ("Pause")"

  9. #9
    Garosie's Avatar Active Member
    Reputation
    18
    Join Date
    Jul 2007
    Posts
    68
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use something like

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    void HelloWorld()
    {
    string Heya;
    cout << "Hello world!" << endl;
    cin >> Heya;
    cin, Heya;
    }
    
    int main()
    {
    int iCount = 5;
    while(iCount < 10)
    {
    HelloWorld();
    }
    }
    it should now keep running the "Hello World" so i made a cin >> Heya; so that it stops to let u write. if u write something like "Hello" it writes "Hello World" again, untill u exit program, whatever u write it will then repeat "Hello world!"


    or for the more noobish programmer :

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    cout << "Hello World!" << endl;
    cin.get();
    }
    Last edited by Garosie; 04-12-2009 at 02:34 PM.

Similar Threads

  1. [Guide] Lua Scripting Guide is here [Updating]
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 93
    Last Post: 11-04-2008, 06:56 PM
  2. Possible to get votes on xtremetop100.com using a script/program?
    By mafiaboy in forum World of Warcraft Emulator Servers
    Replies: 38
    Last Post: 03-08-2008, 12:17 AM
  3. [GUIDE]The Ultiamte Ascent Tutorial
    By evilchickenkiller555 in forum WoW EMU Guides & Tutorials
    Replies: 5
    Last Post: 03-01-2008, 12:57 PM
  4. DVD Burning Guide! 100% Free Programs
    By Nosferattu in forum Community Chat
    Replies: 4
    Last Post: 11-04-2007, 12:56 PM
  5. Guide to needed programs
    By pwner in forum World of Warcraft Guides
    Replies: 8
    Last Post: 07-07-2006, 10:17 AM
All times are GMT -5. The time now is 10:18 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search