Results 1 to 9 of 9
  1. #1
    Arko_0's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Bored

    [Help]Keeping program open

    Hello, I'm fairly new to C++, and I am currently doing as one of the posts I found said to do. I got some books on c++ programming and am currently stuck having a problem keeping a program open after I have compiled and ran it. I am using Bloodshed DevC++ if that helps.

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Add cin.get() at the end of the main function, it waits for user input ( return key ) or you can use system("PAUSE") which I do not recommend because it uses more resources. Just giving you some options.

  3. The Following 2 Users Say Thank You to Void For This Useful Post:

    Arko_0 (08-25-2010),why06 (08-25-2010)

  4. #3
    Arko_0's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Bored
    I have used cin.ignore, cin.ignore(cin.rdbuf()->in_avail() + 1), return 0, and system("Pause") the only one that has worked is system("Pause"). I don't like how it adds the extra line, is there anything else that might work?

  5. #4
    Ionizer's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    105
    Reputation
    30
    Thanks
    9
    My Mood
    Amazed
    Extra line or use visual studio.

  6. #5
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,204
    My Mood
    Flirty
    Also try cin.getch();
    and cin.get(); cin.get(); twice in a row. I think sometimes there's problems with the buffer, and cin.get() will pull a character off of it before it clears or something. not sure

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  7. The Following User Says Thank You to why06 For This Useful Post:

    Arko_0 (08-26-2010)

  8. #6
    Ionizer's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    105
    Reputation
    30
    Thanks
    9
    My Mood
    Amazed
    Just use Visual C++ Express, it automatically adds "press any key to continue" right before the end of the program so it doesn't go away immediatly

  9. #7
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,321
    My Mood
    Cheeky
    Quote Originally Posted by Ionizer View Post
    Just use Visual C++ Express, it automatically adds "press any key to continue" right before the end of the program so it doesn't go away immediatly
    Does it? mine doesnt
    Ah we-a blaze the fyah, make it bun dem!

  10. #8
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Quote Originally Posted by Hell_Demon View Post
    Does it? mine doesnt
    Does for me /

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  11. #9
    Arko_0's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Bored

    Thanks

    cin.get(); cin.get(); worked.

Similar Threads

  1. help i cant open a RAR file plz help me
    By bernardjolly in forum CrossFire Hacks & Cheats
    Replies: 3
    Last Post: 06-11-2009, 05:49 AM
  2. this will help keep new pub stay undetected!!
    By sparda55 in forum Combat Arms Hacks & Cheats
    Replies: 39
    Last Post: 04-16-2009, 04:17 PM
  3. help|How to open 2 accounts in 1 computer?
    By snir3434 in forum WolfTeam General
    Replies: 2
    Last Post: 06-12-2008, 05:01 AM
  4. help to fixing open sloth
    By mojo007 in forum C++/C Programming
    Replies: 3
    Last Post: 04-17-2008, 06:30 PM
  5. [Help]KEEPS SAYING UNREGESTERD
    By Cataldo in forum WarRock - International Hacks
    Replies: 5
    Last Post: 04-16-2007, 04:00 PM