Thread: Press any key to continue? C++

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    11

    Press any key to continue? C++

    OK so, I'm currently making a text based RPG game using C++ in a Microsoft visual c++ IDE. What I'm having trouble doing is finding a way to do a simple "Press any key to continue" to move onto the next cout message. I've ive been doin it in a very annoying way and I know there are much better ways of doing this.
    Code:
    #include <iostream>
    using namespace std;
    
    
    int main()
    int x;
    
    cout << "Random message\n";
    cin >> x;     /* Ive been using cin to move onto the next cout by typing in a random
                           number/character then hitting enter, which then of course allows for the next 
                           cout message to be displayed to the screen */
    
    
    cout << "another random message\n";

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Code:
    #include <cstdlib>
    ...
    system("pause");

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. press any key to continue
    By csonx_p in forum C++ Programming
    Replies: 26
    Last Post: 01-23-2009, 04:52 AM
  2. Press Any Key To Continue?
    By unejam2005 in forum C++ Programming
    Replies: 2
    Last Post: 12-12-2005, 09:38 PM
  3. press a key to continue
    By dP munky in forum C Programming
    Replies: 2
    Last Post: 01-29-2003, 08:51 AM
  4. Press any key to continue...
    By tim545666 in forum C++ Programming
    Replies: 8
    Last Post: 03-03-2002, 09:15 AM