Results 1 to 6 of 6
  1. #1
    P0SEID0N's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    KFC
    Posts
    318
    Reputation
    10
    Thanks
    24
    My Mood
    Lurking

    Learn how to code C++ || Day 2 - Basic Output

    Lesson #2 - Basic Output

    Today we are going to be looking at the acts of output.

    Quote Originally Posted by Juan Soulie View Post
    C++ uses a convenient abstraction called streams to perform input and output operations in sequential media such as the screen or the keyboard. A stream is an object where a program can either insert or extract characters to/from it.
    If this doesn't seem clear to you at the moment, don't worry. You can always come back and re-read it once you have done some practical.

    The first thing your going to do is output "Sup Bitches" onto your screen.
    So start a new project (ctrl + shift + n) and type in (DO NOT copy and paste as you will learn it better if you type it):

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
     cout << "Sup bitches";
     return 0;
    }
    Now press F9 to compile and run it. A window will come up asking you to save it. You must change the file extension from .c to .cpp then save it and continue. The result will look like this.

    [html]Sup bitches[/html]

    Now lets dissect that code.
    #include <iostream>: Standard header needed for outputting and inputting streams
    using namespace std: Explained as simply as possible, namespaces allows us to group a set of global classes, objects and/or functions under a name.Namespace std contains all the classes, objects and functions of the standard C++ library.
    int main(): Initiates the funtion main, which is the main function of the program. Think of it as the trunk of the tree.
    { CODE }: The coding of int main() goes between the parentheses
    cout: Stands for console output
    <<: The << operator inserts the data that follows it into the stream preceding it.
    "TXT": What to output onto the screen.
    Return 0; Returns the function to the value 0
    ; All commands end in a semi-colon


    But what happens if you want to end the line, and start what you next write on the line below? No, you do not have to do spaces until the line is full! All you have to do is either:

    Code:
    cout << "Line one" << endl;
    cout << "Line two";
    
    OR
    
    cout << "Line one\nLine two";
    
    OR
    
    cout << "Line one\n";
    cout << "Line two";
    Thats it for today, ill post up another tut tomorrow about VARIABLES so you can learn to INPUT.

    Credits:
    Juan Soulie
    P0SEID0N
    Last edited by P0SEID0N; 04-13-2010 at 06:30 PM.

  2. The Following User Says Thank You to P0SEID0N For This Useful Post:

    [C]hosen-1 (04-13-2010)

  3. #2
    [C]hosen-1's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    In my house >.>
    Posts
    729
    Reputation
    11
    Thanks
    50
    My Mood
    Psychedelic
    ns bro, ill learn this all ty




    Respect List:
    - [RIP] тιмє
    - ReZaJwZ
    - Ghost
    - Coke
    - [MPGH]Omega
    - Shaunc
    - [MPGH] Petey Piranha

  4. #3
    Spookerzz's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    4,647
    Reputation
    26
    Thanks
    572
    Is this completely your guide?
    I'm back.

  5. #4
    ninlover000's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    hello,

    im completely new to this. After I compiled and ran it, a window popped up saying sup bitches, but the window only remained for half a second and closed. it kept doing that when i kept running it again and again. is it supposed to be like that?

  6. #5
    P0SEID0N's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    KFC
    Posts
    318
    Reputation
    10
    Thanks
    24
    My Mood
    Lurking
    Quote Originally Posted by Godlike View Post
    Is this completely your guide?
    100% Written by me except for the extract from Juan Soulie
    Quote Originally Posted by ninlover000 View Post
    hello,

    im completely new to this. After I compiled and ran it, a window popped up saying sup bitches, but the window only remained for half a second and closed. it kept doing that when i kept running it again and again. is it supposed to be like that?

  7. #6
    Time's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    26,497
    Reputation
    3714
    Thanks
    4,530
    My Mood
    Mellow
    Goood job man.

Similar Threads

  1. Learn how to code C++ || Day 3 - Variables and Date Types
    By P0SEID0N in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 8
    Last Post: 04-16-2010, 09:26 PM
  2. Learn how to code C++ || Day 3 - Variables and Date Types
    By P0SEID0N in forum C++/C Programming
    Replies: 5
    Last Post: 04-16-2010, 02:51 AM
  3. Learn how to code C++ || Day 1 - Compiler
    By P0SEID0N in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 14
    Last Post: 04-15-2010, 02:42 AM
  4. Learn how to code C++ || Day 2 - Basic Output
    By P0SEID0N in forum C++/C Programming
    Replies: 2
    Last Post: 04-13-2010, 08:33 PM
  5. Learn how to code C++ || Day 1 - Compiler
    By P0SEID0N in forum C++/C Programming
    Replies: 5
    Last Post: 04-13-2010, 06:21 PM