Like Tree2Likes
  • 1 Post By bernt
  • 1 Post By CornedBee

Unable to pause program

This is a discussion on Unable to pause program within the C++ Programming forums, part of the General Programming Boards category; Hello I have been programming for a few days now and I have runned inn to a little problem. the ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    1

    Question Unable to pause program

    Hello I have been programming for a few days now and I have runned inn to a little problem. the cin.get(); won't pause my program.

    I have tried to use cin.ignore(); above the cin.get() to make it pause but with no sucsess

    i have also tried to use
    system("pause");

    the compiler I use is called "Microsoft Visual c++ 2010"

    Code:
    #include "stdafx.h"
    
    
    #include <iostream>
    
    
    using namespace std;
    
    
    
    
    int main ()
    {
        cout << "Hello world\n";
        cout << "Here is 5: " << 5 << "\n";
        cout << " the manipulator endl writes a new line to the screen." <<
            endl;
        cout << " Here is a very big number:\t" << 70000 << endl;
        cout << " Here is the sum of 8 and 5:\t" << 8+5 << endl;
        cout << " Here's a fraction:t\t" << (float) 5/8 << endl;
        cout << " and a very very big number:\t" << (double) 700 * 700 <<
            endl;
        cout << "Don't forget to replace Jesse Liberty with your name...\n";
        cout << "shacko is a C++ programmer!\n";
    
    
        
        cin.get();
        return 0
    }

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    There's no semicolon after the "return 0". I don't know if this was a copy-paste error, but it's possible that you were just running the last successful build (presumably from before you inserted the cin.get()).

    If that is the issue, I'd recommend changing this setting for future use:
    In the Projects and Solutions options: Build and Run -> On Run, when build or deployment errors occur -> Prompt To Launch

    Then VS will bring a message box up if the build fails.
    iMalc likes this.
    Consider this post signed

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    19
    You can type getchar();it does the same job.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    The real question is, why do you want to pause the program? Launch it with Ctrl+F5 instead of just F5 and Visual Studio will keep the console open for you.
    Elysia likes this.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Jan 2012
    Posts
    9
    i use. i dont know if they work very well but they do the job for me...maybe they will help you untill you learn a better method
    Code:
    cin.ignore();
    cin.get();

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    CornedBee just mentioned a better method right above your reply!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pause a C program without getch()
    By swgh in forum C Programming
    Replies: 4
    Last Post: 02-20-2006, 10:24 AM
  2. Why won't my program pause?
    By ladysniper in forum C++ Programming
    Replies: 4
    Last Post: 02-13-2006, 02:22 AM
  3. How do you pause a program?
    By Elite in forum C Programming
    Replies: 3
    Last Post: 03-14-2005, 06:45 AM
  4. pause program at console
    By datainjector in forum C# Programming
    Replies: 1
    Last Post: 03-26-2003, 11:36 PM
  5. How do I make my program pause
    By quiksilver9531 in forum C++ Programming
    Replies: 9
    Last Post: 01-23-2002, 06:38 PM

Tags for this Thread


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