Thread: Complete Beginner, HELP!!

  1. #16
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    >>but now when it compiles a DOS window opens for less than a second and then closes again?! is this normal?

    Yes, its perfectly normal. Your computer runs the program and then once its finished the program closes. You haven't told it to pause.

    Place this just after your "cout<<.." line;
    char Q;
    cin >> Q;
    That will make it so once you press a key followed by enter the program will close.

    >>Also, now i use the using namespace std; underneath the <iostream> does it mean I have to use this in EVERY script, does it

    Yes, every script that has #include <iostream>. You'll learn why you have to do this later (much much later).

  2. #17
    Registered User
    Join Date
    May 2003
    Posts
    42

    an answer!

    Hey britney!
    add this just below (#include <iostream>)

    #include <stdlib.h>
    ----------------------------------
    and add this also on top of (return 0

    system ("pause");
    =======================================
    your program should look like this:
    Code:
    #include <iostream>
    #include <cstdlib>
    using namespace std;
    int main()
    {
       cout << "Hello Mr.Gates, MICROSOFT sucks!\n";
       system ("pause");
       return 0;
    }

    Try it, it'll work!
    I'm also using Dev-C++ IT ROCKZ!!!
    look, I'm just a bigenner like you, just a bit better, lol
    keep asking and get a bigenners C++ book.
    no one is born with knowledge, you have to get it yourself

    And guys!
    what's (using namespaces std ?
    tell me all about it, I see no difference when putting or removing it from my code!
    Last edited by Nectron; 06-12-2003 at 02:08 PM.
    I have a code which stops life!

  3. #18
    Registered User
    Join Date
    Jun 2003
    Posts
    8
    ok i can get using namespace std; to work but if i put #include <stdlib.h> underneath 'inclde iostream it wont compile. but the namespace std works

  4. #19
    Registered User
    Join Date
    May 2003
    Posts
    42

    I dont understand you

    look, I didn't understand what you said, but here's your code, it's perfect...
    works fine with dev c++ 4

    Code:
    #include <iostream>
    #include <cstdlib>//for system pausing
    using namespace std;
    
    int main()
    {
       cout << "HEY, you, I'm alive! Oh, and Hello World!\n" << endl; /*ends the line*/
       system ("pause");// make the system ask for pressing a key to terminate
       return 0;
    }
    Last edited by Nectron; 06-12-2003 at 02:10 PM.
    I have a code which stops life!

  5. #20
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    <stdlib.h> is a deprecated header (like <iostream.h>). Instead use <cstdlib> with the std namespace. Same thing goes for all standard C headers included in the C++ standard: the new names for <header.h> are <cheader>.

    You could also run your program from the shell. That way you would need to pause it to see the output (i.e. open a DOS prompt, cd into the program directory, and type "prog-name.exe").
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  2. Help out a complete beginner
    By Jmcrofts in forum C++ Programming
    Replies: 7
    Last Post: 07-28-2007, 12:09 PM
  3. Complete Beginner [Need Help]
    By Vintik in forum C++ Programming
    Replies: 10
    Last Post: 08-15-2005, 05:08 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  5. doom lord engine complete!
    By Leeman_s in forum C++ Programming
    Replies: 4
    Last Post: 04-25-2002, 08:41 PM