Thread: windows console probs

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

    windows console probs

    i am trying to program stuff, and whenever i run it on my compiler(borland), my console window pops up and down. looked in faq, it couldn't really help me. maybe someone could help me out by telling me how to change directory from a C: prompt, when i try to put in a "please press enter to continue..." type code, my console disapears. help.
    thanx

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    You can use something like this:

    cout<<"Please hit a key to continue."<<endl;
    cin.get();

    See the faq here:

    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    As for why that happens, see here:

    http://forums.devshed.com/t60302/s86...f92edf3c7.html
    Last edited by 7stud; 05-04-2003 at 02:46 PM.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Use getch() just before you exit main().
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Student Forever! bookworm's Avatar
    Join Date
    Apr 2003
    Posts
    132
    Wow!
    Henroid, a long time back, I had posted this same querry on this very board.
    And I am passing to you the reply given to me,hoping that someday,you too will give this reply to a novice C++ programmer and save his/her day.
    Simple, ethier type
    std::cin.get();
    std::cin.get();
    before the "return 0;" in int main()

    Or, type
    std::cin.ignore();
    std::cin.get();
    before return 0; in int main()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. One process with two console windows
    By siavoshkc in forum Windows Programming
    Replies: 8
    Last Post: 01-30-2009, 04:13 PM
  2. Question about console and windows programming
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 06-22-2002, 05:46 AM
  3. multiple console windows
    By gordy in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-13-2002, 11:05 PM
  4. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM
  5. windows dos console
    By dune911 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-16-2002, 11:30 PM