Thread: Dos Window closes after I press enter

  1. #1
    Registered User ProgrammingDlux's Avatar
    Join Date
    Jan 2002
    Posts
    86

    Question Dos Window closes after I press enter

    If anyone can help i'd appreciate it.

    I'm writing a program that accepts input "cin>>".

    I declare the variable and all, but when i input it during execution, the DOS Window automatically closes and brings me back to the Compiler. What's up with that?

    Any help is appreciated.
    Thanks

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    http://www.cprogramming.com/boardfaq.html#pause

    or compile from the command line...

  3. #3
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    also code would be useful
    Monday - what a way to spend a seventh of your life

  4. #4
    Registered User ProgrammingDlux's Avatar
    Join Date
    Jan 2002
    Posts
    86

    An example

    This is what I was talking about referring to the "cin>>" problem.


    #include <iostream.h>
    main()
    {
    int S1=15, S2=20;

    cout<<"\n Enter Score 1, Press Enter Key: ";
    cin>>S1;
    cout<<"\n Enter Score2, Press Enter Key: ";
    cin>>S2;

    return 0;
    }

    No Matter what I type, after "Press Enter Key: " (after i compile and run of course) ..the Dos Window closes when i press enter. Why is that? and is this program written correctly?

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Follow the link I posted - it'll answer your question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. hi need help with credit limit program
    By vaio256 in forum C++ Programming
    Replies: 4
    Last Post: 04-01-2003, 12:23 AM
  4. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 04:49 PM
  5. Dos window displays while compiling
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 01-02-2002, 02:59 PM