Thread: Still a newbie =(.

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    2

    Still a newbie =(.

    Well I am reading the Tut's on C++ Proggraming and when I compile and build my prog (DOS Based) with MS Visual C++ I enter something like what my age is, Id put 104 and it would close, I am using Win XP Pro, do you think it has to do something with XP's piece of #### CMD?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    it has nothing to do with XP.
    it has to do with your code.

    do a search, this has been discussed before...

    http://www.cprogramming.com/boardfaq.html#pause

    click that link, it will help you.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    A very common question.....

    try adding cin.get(); at the end of the program to pause it. You then press enter to make it continue.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    XP is not a piece of crap. I find it very stable and much better than any other Windows I've ever used.

    What you just told us has NOTHING to do with Windows and EVERYTHING to do with you. I bet you messed up the code. Try posting it and we'll be glad to help.

    Hehe, its the closing thing....
    Code:
    #include <stdlib.h>
    int main()
    {
       system("pause");
       return 0;
    }

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    2
    That was a fast reply(s)!

    Code:
    #include <iostream.h>
    
    int main()
    
    {
    
      int thisisanumber;
    
      cout<<"Please enter a number:";
    
      cin>>thisisanumber;
    
      cout<<"You entered: "<<thisisanumber;
    
      return 0;
    
    }
    If I enter a number and press enter it will just close.

  6. #6
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    ... read what everyone's posted
    "He who makes a beast of himself, gets rid of the pain of being a man." Dr. Johnson

  7. #7
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    Think about it...you're not opening up a new instance of cmd or command.com, so why would it NEED to stay open? It doesn't. You don't tell it to stay open, so why should it?

    As was said, use cin.get() or getch() or kbhit() or blahblahblahblahblah...

  8. #8
    Registered User
    Join Date
    Jan 2003
    Posts
    88
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    int main()
    
    {
    
      int thisisanumber;
    
      cout<<"Please enter a number:";
    
      cin>>thisisanumber;
    
      cout<<"You entered: "<<thisisanumber;
      system("pause");
      return 0;
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM