im extreamly new help

This is a discussion on im extreamly new help within the C++ Programming forums, part of the General Programming Boards category; in the FIRST tut. it says to put this Code: #include <iostream.h> int main() { cout<<"HEY, you, I'm alive! Oh, ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    12

    im extreamly new help

    in the FIRST tut. it says to put this

    Code:
    #include <iostream.h> 
    int main() 
    {
      cout<<"HEY, you, I'm alive!  Oh, and Hello World!"; 
      return 0;    
    }
    y when i complie it and run it the window closes INSTANTLY?
    im using DEV-C++

  2. #2
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Search The Board You F-ing F-er!
    FAQ FAQ FAQ
    Do not make direct eye contact with me.

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    12
    jeez thx anyways

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    62
    Hey ringo I'll help you

    I dont think people on here half the time argue about this but the easiest way to get started is to make sure you put after
    #include (iostream)
    is
    using namespace std;

    and even if people dont think its a good idea to use, as someone new, it wont matter in the slightest.

    Enjoy programming dont let anyone put you off, and reach as far as you want to go, that's what I am doing and I will get there!

  5. #5
    Registered User
    Join Date
    Apr 2004
    Posts
    12
    k thx i got the idea now

  6. #6
    Registered User
    Join Date
    Feb 2003
    Posts
    62
    My Pleasure!

  7. #7
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    I'm gonna go kill myself now.
    Do not make direct eye contact with me.

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    12
    what is the point of LOOPING?
    what can it be used for?

  9. #9
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    looping can b used to count, thats the simples example lol if u want to add numbers from1 to 10 u use a loop to do it
    When no one helps you out. Call google();

  10. #10
    Registered User
    Join Date
    Apr 2004
    Posts
    12

    Question

    i need help again......how would i make this loop 2 times?
    thx for helping peoples

    Code:
    #include <iostream.h>
    int main()
    {
      int x;
      x=0;
      do
      {
        cout<<"Hello world!";
      }while(x!=0);        
      
    return 0;
    }
    i tryed changing the while(x!=0); TO while(x!=2);
    but it repeats endlessly
    Last edited by rigo305; 04-23-2004 at 06:27 PM.

  11. #11
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    That's a for loop

    Code:
    #include <iostream>
    
    int main()
    {
       int x;
       for(x=0; x<2; x++) //set x to 0, while x is less than 2, increase x by one each time
       {
          std::cout << "Hello world!" << std::endl;
          getch();
       }
       return 0;
    }
    I didn't test it... may be a problem or two...

  12. #12
    Registered User
    Join Date
    Apr 2004
    Posts
    12
    oo great thx ic know

  13. #13
    Registered User
    Join Date
    Apr 2004
    Posts
    12
    what does std:: mean?
    EDIT: is it needed?
    Last edited by rigo305; 04-23-2004 at 06:39 PM.

  14. #14
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    That means that whatever member on the right of it is part of the std namespace.

    You can think of namespaces as a way to organize your code. Functions, definitions and data that share a common task can be put into a namespace so that others can use the same names you used (common names like create, destroy, etc) but be in a different namespace.

    You can place std:: in front of all the standard library members but you don't have to if you include them all in at once, or one at the time:
    Code:
    using namespace std;  // all at once
    
    // one at the time
    using std::cout;
    using std::endl;
    The std:: is needed unless you do one of the above.

  15. #15
    Registered User
    Join Date
    Apr 2004
    Posts
    12
    o ic
    so i can write

    is
    using namespace std; //at the top right?

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21