Ask Experts Questions for FREE Help !
Ask
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #1

    Aug 5, 2007, 01:35 PM
    How do I get it to stay on screen
    OK, I've written this programme and I've compiled it but when I run it I enter some numbers and words then I have to press enter to get there but as soon as it displays it it closes how can I make it so it doesn't do that
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #2

    Aug 5, 2007, 03:37 PM
    Hello
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #3

    Aug 6, 2007, 08:09 AM
    Anybody there
    asterisk_man's Avatar
    asterisk_man Posts: 476, Reputation: 32
    Full Member
     
    #4

    Aug 6, 2007, 09:47 AM
    At the end of your code output something like "press enter to quit" and then read in one more character. This way you'll wait for the user to do something before the program terminates.
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #5

    Aug 6, 2007, 03:58 PM
    I've tried that but it still closes after I put my information in then press enter to continue but it just goes dtraight to the end of the programme then closes in an instant
    asterisk_man's Avatar
    asterisk_man Posts: 476, Reputation: 32
    Full Member
     
    #6

    Aug 6, 2007, 05:55 PM
    No, put the "press enter to continue" as the very last thing in main()
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #7

    Aug 7, 2007, 03:37 PM
    I put a code in which I was told coded for that just before the Return 0, could you give me an example of the code you mean
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #8

    Aug 8, 2007, 02:32 PM
    This is the bit I put it

    Cout << "Press Enter to exit";
    Cin.ignore(std::cin.rdbuf()->in_avail() + 1);
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #9

    Aug 10, 2007, 07:00 AM
    Any advice would be great
    asterisk_man's Avatar
    asterisk_man Posts: 476, Reputation: 32
    Full Member
     
    #10

    Aug 10, 2007, 05:45 PM
    I'm not sure what it is you're trying to do with the second line you listed. I've not used iostream in a while but I think something like this will work:

    Code:
    char junk;
    cout << "Press Enter to exit" << endl;
    cin >> junk;
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #11

    Aug 11, 2007, 07:36 AM
    Quote Originally Posted by asterisk_man
    i'm not sure what it is you're trying to do with the second line you listed. i've not used iostream in a while but i think something like this will work:

    Code:
    char junk;
    cout << "Press Enter to exit" << endl;
    cin >> junk;
    OK it stays on screen after I put the information in but it doesn't close after I press enter, the line that you said you wernt sure on it has that line in the book and its worked before to make my text stay on screen
    asterisk_man's Avatar
    asterisk_man Posts: 476, Reputation: 32
    Full Member
     
    #12

    Aug 14, 2007, 06:20 AM
    If you're really stumped you can always fall back on plain c and use stdio.h
    Code:
    getchar();
    Nosnosna's Avatar
    Nosnosna Posts: 434, Reputation: 103
    Full Member
     
    #13

    Aug 14, 2007, 06:35 PM
    Cin >> tempchar; will only work if you actually give it a character to read... just pressing return won't advance the program.

    If, instead, you use cin.get(tempchar); it will behave the way you want.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search


Check out some similar questions!

Blank screen after xp splash screen and then hangs [ 2 Answers ]

My colleagues and I work in a tech environment and we have seen several computers with the same symptoms. Namely a failure to boot xp. After the xp logo screen the screen goes to blank and it just hangs. This looks like a graphics card fault but changing card does nothing. Booting into safe...

Black screen after windows splash screen windows xp [ 2 Answers ]

Black screen after windows splash screen windows xp

Having a problem moving my address bar from bottom of screen to top of screen [ 11 Answers ]

Hello everyone, I can't seem to bring up an address bar at the top of the screen because when I right click at the top of the page, the options are not lit up. I could only bring up an address bar at the bottom. Since it gets in the way at the bottom, I would like to know if anyone can help me...

Screen [ 1 Answers ]

Customize my desktop? If not there should be laptop settings to set the resolution and screen size

Pc on, nothing on screen [ 5 Answers ]

My PC turns on, no boot, nothing on screen, help?


View more questions Search