Results 1 to 7 of 7
  1. #1
    kingnoobe's Avatar
    Join Date
    Jul 2008
    Posts
    104
    Reputation
    10
    Thanks
    5

    Starting to learn c++

    I need just a little help getting started.. I'm understanding most of it *not that I'm far or anything*. But I don't get the braces.

    #include <iostream>

    using namespace std;

    int main()
    {
    cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
    cin.get();
    }

    Why couldn't I use a semicolon after int main and cin.get... Instead of using the braces.. Is it because int main is a function thus requires the braces.. And cin.get is that because its a function, but why does it have the semicolon then if its already ended. I actually get the rest of that...cout...#include <iostream>..etc...

    I know I'm a complete newb, but hey we all had to start somewhere, and this tut. does seem pretty good just isn't quite clear on this.

  2. #2
    skittlznick2's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Location
    YOUR MOM KNOWS
    Posts
    87
    Reputation
    10
    Thanks
    8
    It would be much easier to just do

    cout << "whatever you put here"<< endl;
    cin >> whatever u named it;

    You couldnt put a semicolon after int main because thats not a line of code really...same thing with cin im terrible at explaining..
    Last edited by skittlznick2; 08-02-2008 at 07:03 PM.

  3. #3
    phantomfury's Avatar
    Join Date
    Jul 2008
    Posts
    6
    Reputation
    10
    Thanks
    0

    Exclamation

    The code I use for (Hello World):
    (Remember I was using the CLR Application)
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main (void)
    {
         Cout<<"Your message here!n";
         system("PAUSE")'
         return 0;
    }

  4. #4
    Sinful's Avatar
    Join Date
    Aug 2008
    Gender
    female
    Posts
    3
    Reputation
    10
    Thanks
    0
    Um, i'm fairly new myself but { and } just mean start and end of a code block. int main() is indeed a function, it's the main function where all or most of your code will execute. More or less it's just a open and close to a funtction. The semicolen is there just as end each line in the function. Correct me if i'm wrong.
    Last edited by Sinful; 08-06-2008 at 08:10 PM.

  5. #5
    ShabbaStoney's Avatar
    Join Date
    Aug 2008
    Posts
    9
    Reputation
    10
    Thanks
    7
    int main() is your function. the get() in cin.get() is some one elses function that you are calling. Think of the semi colons as representing different commands. I.e. cout << .... ; is the first command the computer executes then it goes right done that what next! ahhhhh cin.get(); do that nothing else? ok see ya!

    Hoepfully that will clear things up I'm not too good at explaining things :P

  6. #6
    djtrickdog's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    25
    Reputation
    10
    Thanks
    1
    im guessing you are using cin.get to wait for a user to press a key?
    instead use:
    Code:
    getchar();
    or
    Code:
    System("pause"); //outputs "Press a key to continue"
    or
    Code:
    System("pause>nul"); //no output
    and use return 0; before the final bracket "}"

  7. #7
    Oneirish's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    3Oh!3, Colorado
    Posts
    4,568
    Reputation
    876
    Thanks
    866
    My Mood
    Inspired
    Go to cplusplus.com - The C++ Resources Network and do their tutorials. That's where I learned it...

Similar Threads

  1. Starting to learn making hacks.
    By SofaKingH4rd in forum General
    Replies: 19
    Last Post: 08-04-2011, 12:19 PM
  2. I'm starting to learn..
    By Jessika in forum General
    Replies: 44
    Last Post: 03-11-2011, 10:55 PM
  3. A place to start to learn C++
    By DawgiiStylz in forum General
    Replies: 5
    Last Post: 10-05-2009, 09:49 AM
  4. HELP: What other programs do I need to learn/start hacking?
    By ronyoung08 in forum General Hacking
    Replies: 0
    Last Post: 08-01-2008, 09:40 PM
  5. I wanne start learning Assembly plz read.!
    By Niratsio in forum Visual Basic Programming
    Replies: 14
    Last Post: 10-31-2007, 08:05 AM

Tags for this Thread