Pausing

This is a discussion on Pausing within the C++ Programming forums, part of the General Programming Boards category; Hey everyone, I am new so be nice. I was wondering how to pause the program to let the user ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    Pausing

    Hey everyone, I am new so be nice.

    I was wondering how to pause the program to let the user read the output so far I have (note that this program is stupid and was just to figure out how to pause the program):

    #include <iostream.h>
    #include <stdlib.h>

    int main()
    {
    int i;
    int f;

    cout<<"Hello world!\n";
    cin>>i;
    cout<<"Counting from 0 to "<<i<<endl;
    cout<<"----------"<<endl;

    for (f = 0; f <= i; f++) {
    cout<<f<<endl;
    system("PAUSE");
    }

    cout<<"----------"<<endl;

    system("PAUSE");

    return 0;
    }

    this program does not pause where I put 'system("PAUSE");' any solutions will be greatly appricated. Thanks in advance.

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    looks like there is nothing wrong with your code and it compiled perfectly in Dev C++ and worked exactly like its meant to (it pauses when its meat to). So I don't know what the problem is with your compiler or computer that isn't working...

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4
    oh I forgot to mention that I am using Microsoft Visual C++ 6.0 so that must be the problem. (I am most likely wrong here).

    I have Dev C++ at home, but at school they only have Microsoft Visual C++.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4
    One more thing...

    When I compile the program and build the .exe when I run it it automatically closes, is there a way to stop it from doing this or at least get it to wait long enough to see the output?

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    use system("pause");

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    22
    Try using this command... you might need to include <conio.h> or <stdlib.h>

    cout<<"\nPress any key to continue."<<endl;

    getch();

    if it wants you to input a character before it outputs the cout statement, you need to put

    cin.ignore(1000,'\n');

    before the cout.
    <^>( * ; * )<^>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pausing script to read output
    By a_priebe47 in forum C Programming
    Replies: 1
    Last Post: 06-15-2004, 10:16 PM
  2. pausing functions..
    By bluehead in forum C++ Programming
    Replies: 3
    Last Post: 01-13-2002, 02:27 AM
  3. Functions and pausing
    By dv916 in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2001, 04:43 PM
  4. MS DOS not pausing while waiting for imput.
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-14-2001, 08:06 PM
  5. pausing the system
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 10-18-2001, 12:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21