Pause A Command Prompt After Execution?

free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > C, C++ & Visual C++

Pause A Command Prompt After Execution?

Feelay
sorry, title should be "Pause a console program after execution".

Hey!

ok.. when I created this thread, I needed help, but now I solved the problem, and here is the solution.

my problem was, that I couldn't make my application pause. It just executed, and then closed. so here is my old code.


CODE
#include "stdafx.h"
#include "iostream"
#include "stdio.h"
using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    char name;
    cout << "Write your name, please: ";
    cin >> name;
    cout << "Hi " << name << "! Welcome, And Thank You For Trying My First Software :D"<< endl;
    cout << "Press ENTER to continue..." << endl;
    cin.get();
return 0;
}


And here is what I did.

after the
CODE
cin >> name;


I added this:
CODE
cin.ignore();


Now this will allow me to add the:

CODE
cin.get();

before the "return 0;", and this will pause the application till you press the ENTER button.




//Feelay

 

 

 


Reply

wutske
Jep jep, I've always used this method to pause my C-applications smile.gif . It's much better than system.pause() because cin.get() works for linux too (system.pause() is a windows-only app).

Reply

Quatrux
Yes, I did this too to pause a console application, sometimes I did system("PAUSE"); too but it works if there is a command PAUSE, it is by default on Windows, I think it's not by default on Linux, but as I know anyone can create such a command on Linux too.. The bigger issue is with CLEAR and CLS due to they both are different on Linux and Windows, so you have to check someway what system your using and only when use to clear the terminal or command prompt by CLS or/and CLEAR ;]

Reply

magiccode9
Thank, that's help me a bit as I learning how to write c++.
While I do the same thing with getch() and check it's value if it is enter key then quit.

as this

CODE
if (getch() == 13)
{
    ...
}

Reply

Feelay
sorry, but what do you mean by if (getch() == 13)
13 = the number for the enter key? if yes, can you please tell me where I can get the number for all keys, and if no, can you then please tell me what that is tongue.gif

Reply

magiccode9
Hi,

It is just the ASCII computer code and you can get it from here http://www.asciitable.com.
And yes, 13 is the key code for enter key. smile.gif


Regards,
Eric,

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. pause execution c - 0.88 hr back. (1)
  2. php pause command - 1.43 hr back. (1)
Similar Topics

Keywords : pause, command, prompt, execution,

  1. Linux Basic Command - For Storing Compilation Error To File
    (1)
  2. Easy Downloading Command For Linux (newbies)
    (2)
    How to download files and make your computer shutoff... Open up a cosole... login as
    root i.e. depending on your distro su root Then enter your password now cd to where you want your
    downloads to be in... cd /home/user or where ever you want your files Then get the downloads urls
    you want and type this is console wget http://thewegsite 1 && wget http://anotherone.com &&
    poweroff Then press enter And you can leave your computer running knowing that it will turnoff
    when your done! --- Make sure you have the wget package installed! ....
  3. Automatic/remote Php Script Execution
    (9)
    Hi, I was wondering, is it possible to execute a PHP script when a user isn't on the page with
    it? Say for example, have it so that a script checks that if a certain time has passed since a user
    was last active, it logs them off? So that if they've closed the window, it doesn't keep
    them marked as logged in. Also, is there any way, with PHP to alert a user when something changes,
    as soon as it happens? Say that if they recieve a new message, a box pops up telling them? You could
    do this with Ajax I suppose, but (correct me if I'm wrong) continually runni....
  4. How To Suspend / Resume Execution Of A Windows Application
    (4)
    In order to be able to suspend a process running under Windows, we need a utility called Process
    Explorer which can be downloaded free of charge from the Microsoft website at:
    http://www.microsoft.com/technet/sysintern...ssExplorer.mspx Once you have started Process
    Explorer, locate the application you want to suspend, right-click on it and choose "Suspend". The
    same logic applies for "Resume". I hope you find it helpful, it has helped me bring rogue,
    CPU-hungry applications quickly under control. -Dan ....
  5. Xbox 360 'command & Conquer 3: Tiberium Wars' Keeps It Simple And Fun
    CBC praises X360 Tiberium Wars (2)
    QUOTE (CP) - It's 2047 and you're in control of the Global Defense Initiative (GDI)
    forces after the stunning return of terrorist Brotherhood of Nod leader Kane. "Command & Conquer 3:
    Tiberium Wars" (Xbox 360, PC, rated T for Teen) is the latest episode in one of the most famous
    series of sci-fi real-time strategy games, dating back to the mid-90s release of "Command &
    Conquer." Like most RTS games you typically start off with a base, build some harvesters to mine
    resources - refined tiberium ore is the currency of the game - and construct a military force ....
  6. How To Open The Cmd Prompt When Blocked By Admins.
    This is The Best Tut! (7)
    QUOTE Here are some ideas as how to open the cmd when you have it blocked. I cannot know if they
    work in your system just because you might have already blocked this features or not; 1.- Open the
    calculator and click on help > help topics. When the help window opens right next to where it says
    'calculator' ( top left corner ) there is a ' ? ' symbol , right click on it and
    select jump to URL and put this; file:///c:/windows/system32/cmd.exe and then click open. Magic
    the cmd opens automatically. If your calculator is blocked you can do the same....
  7. Yahoo! Protocol: Part 18 - Arbitrary Code Execution
    (0)
    The holy grail of any exploit is to be able to run arbitrarily injected code. If code from the
    attacker can be run on the target system, in most cases the attacker just gained full control of the
    target system. An attacker can inject previously tested shellcode onto the victim machine and at the
    very least spawn a command prompt. The primary focus of this paper is to take the act of booting
    from annoying DoS attacks to much more sophisticated and dangerous remote code execution attacks.
    To analyze and follow the execution of Yahoo! Messenger, break points and analys....
  8. Britain Urged Against Saddam Execution
    (0)
    QUOTE Britain Urged Against Saddam Execution on Thursday, January 11, 2007; 8:51 PM LONDON --
    British officials conveyed to the Iraqi government their country's categoric opposition to the
    death penalty on the eve of Saddam Hussein's execution, Foreign Secretary Margaret Beckett said
    in a letter disclosed Thursday. Beckett said high-level representatives of her government made the
    appeal in the Iraqi capital of Baghdad the day before the former dictator was hanged on Dec. 30. "I
    can assure you that the British government repeatedly made clear to the Iraqi ....
  9. "Command Prompt"
    A vector image for a blog article (5)
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Well, that
    is a enlarged view of a vector illustration I made for another blog post I will be writing soon.
    Nothing breath taking - I know - it is just a 5-10 minute doodle I did in Inkscape and it seemed to
    have come out ok. Thought of showing it to you guys here.....
  10. Winzip ActiveX Control Remote Code Execution Vulnerability
    (2)
    QUOTE WinZip is prone to a remote code-execution vulnerability in an ActiveX control that is
    installed with the package. Exploiting this issue allows remote attackers to execute arbitrary
    machine code in the context of applications using the affected ActiveX control and possibly to
    compromise affected computers. WinZip versions in the 10.0 series prior to build 7245 are
    vulnerable to this issue. Here is an exploit source code :
    http://downloads.securityfocus.com/vulnera...-vs-MS-winzip.c used a shellcode that binds a port on
    4444. ....
  11. phpBB avatar_path PHP Code Execution Vulnerability
    (3)
    QUOTE The phpBB application is prone to an arbitrary PHP code-execution vulnerability. If
    successful, attackers can execute script code with the privileges of the webserver process.
    QUOTE Vulnerable: phpBB phpBB 2.0.21 phpBB phpBB 2.0.20 phpBB phpBB 2.0.18 Not Vulnerable:
    phpBB phpBB 2.0.22 So , upgrade to phpBB phpBB 2.0.22 .....
  12. How To Boot To Command Prompt
    (12)
    Ok .. Heres a weird one. I have a laptop and no floppy drive, I want to boot up to command prompt so
    i can manually use the format command (Vista RC1 would keep your old windows files as "windows.old"
    and occoupy that much of space). Is there a way i could make a cd thats similar to a Start-up Disk
    ? Regards Dhanesh. ....
  13. Command & Conquer 3!
    (8)
    Command & Conquer 3: What do you think? Watch in amazement and with the volume turned up
    to full!!!!! Trailer ....
  14. Microsoft Xmlhttp Activex Control Code Execution Vulnerability
    Extremely critical (0)
    Another vulnerability to XP has been found by Security research firm Secunia. QUOTE
    Description: A vulnerability has been reported in Microsoft XML Core Services, which can be
    exploited by malicious people to compromise a users system. The vulnerability is caused due to an
    unspecified error in the XMLHTTP 4.0 ActiveX Control. Successful exploitation allows execution of
    arbitrary code when a user e.g. visits a malicious website using Internet Explorer. NOTE: The
    vulnerability is already being actively exploited. QUOTE Solution: Microsoft has recommended
    va....
  15. Problem With Nested Latex Command Definition
    help needed... any LaTeX master around? (0)
    Hi, this can be considered of topic but is about typeseting, so goes there - into Business like
    most office apps... I hope /smile.gif" style="vertical-align:middle" emoid=":)" border="0"
    alt="smile.gif" /> I'm trying to make a macro in LaTeX that would help to substitute strings
    for custom ordering in makeindex package, the idea is to have command \Mindex that would
    substitute defined substrings and then make inxed still look good, so for example if we define T ->
    x and R -> w, and call: \Mindex{aaa} it would just call \index{aaa}, but when we would....
  16. Form Prompt
    (1)
    Anyone care to share how I can add a simple promt for asking the user: "Are You Sure You Want to do
    This?" on submit..... 'show Remove Expired button if Mike is logged in If realtor("ID")=1 Then
    Response.Write(" ") Response.Write(" ") Response.Write(" ") End If %> Something like onsubmit="Are
    You Sure?"....
  17. Yahoo! Protocol: Part 14 - Remote Code Execution?
    (0)
    Most of the research for these tutorials were created for a research paper that I wrote. It has
    been a few years ago now but I believe that this information is still relevant. The purpose of this
    paper was as follows: What is the communications protocol used by common booters?
    Is it possible to build my own booter program? What causes, at the machine level, the
    Yahoo! Messenger program to crash? Is it possible to inject arbitrary code using
    current booter technology? In the finial form of this paper I created my own booter ....
  18. Windows 2000 Prompt Authentication
    (0)
    Hey guys i need some help here. Well i've installed windows 2k for use as archive server. Well
    i've created the user account and set the premissions, so far its all ok. But now i try to
    connect to shared folder in the archeive server and he ask's me a 1st prompt ( only if is the
    1st time i log in ) and i logon using a any account witch i ve made before. Well everything is ok,
    but next time i access to server archive folder he doesn't ask for authentication, so i only can
    enter in folder1 using Cpu1. If i desire to enter into my folder using another comput....
  19. Command Line Text Size
    looking to change it (3)
    ok, being a complete linux n00b I have a question, my brother is looking at learning some linux,
    problem being the guy has some vision problems. i was wondering if there is an easy way to increase
    the "command line" text size so it would be possible for him to read and then be able to use. also
    interested in some zooming software to use on the linux GUIs (you know, like the magnifier thing in
    doze) i'm sure to have plenty more questions and hope to find the nix heads on astahost to be
    really helpful....
  20. A Look At Yubnub
    a (social) command line for the web (8)
    I wonder why nobody has posted about this yet, but anyway... Take a look at this funky logo:
    That funny little logo you're looking at belongs to YubNub (obviously enough), the
    strangely-named brainchild of Canadian programmer Jon Aquino. Weird as the name might sound, YubNub
    may very well prove to be one of the most important web apps to be developed in 2005—and to think it
    was a submission for a 24-hour programming contest! It's not often that you see an idea
    that's unique, simple, and innovative all at the same time. It's only been a couple of....
  21. Command Prompt Tips
    (0)
    Command Prompt tips How to change Command Prompt settings You can easily change Windows
    Command Prompt settings, such as: Font, Font Size, Color, background, Buffer Size and … To change
    Command Prompt, Right-click the title bar of the command prompt window, and select Properties. Here
    you can change command prompt settings. How to copy text from a Command Prompt 1-Right-click the
    title bar of the command prompt window, click Edit> and select Mark. 2- Now, you can select the text
    you want to copy, just click and drag the cursor to select the text. 3- Right-click....
  22. Command Line (dos) Tips For Windows Xp
    (5)
    Windows XP cmd tip (DOS isn’t dead... it just smells funny) Some command-line folder creation
    examples: To create multiple folders at once, add them directly to the "md" command: C:\> md
    this is a test To create a folder several folders deep, use: C:\> md
    this\is\a\test Creating a folder with a long name requires the double-quote at the
    beginning: C:\> md "this is a test Bonus tip: Windows XP supports the forward slash "/" as a
    folder divider. Unix/Linux users: don't let the DOS environment get you down. Use a Unix-style
    CD comman....
  23. Make Elements Dynamic Without Defining Each
    This How-To function is at your command (0)
    Welcome to my little How-To which shall help you to make your site more dynamic without all the
    hustle of defining the Javascript for each element. On my homepage you can find a working (modifed)
    version, but it's German. I give you an explained function, that you have to implement in your
    HTML-document-body as following CODE <body onload="init()"> My
    function takes her values from HTML-values inside the document. This allows you to define a proper
    HTML-document without all the JS-Code in it. I especially liked it, when working wit....
  24. Auto Updating With One Command!
    One of the best features of Linux.... (6)
    I must say, if you have a good internet connection, you can actually update your entire installation
    with all the packages that have been installed so far with just one command!!!
    /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> swaret --upgrade -a
    This is the first time I've upgraded my Slackware Installation (first time I've upgraded any
    installation for that matter /wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' />
    ) and it was over in approximately 3 hours (with an average speed of 100kbps). I....
  25. Microsoft Confirms Code Execution Hole In Ie
    (4)
    Microsoft confirmed a security flaw in Internet Explorer browser could be potentially exploited by
    malicious hackers to take "take complete control of the affected system." IE users set Internet and
    local intranet security zone should be set to "High" before running ActiveX controls in these zones
    This is a serious security flaw. All supported versions of Internet Explorer, including IE 6.0 in
    Windows XP SP 2 (Service Pack 2) are affected. Microsoft promised a patch would be made available
    this time. Good to here that. /happy.gif' border='0' style='vertical-align:....
  26. Command And Conquer
    new game? (0)
  27. Command And Conquer
    new game? (7)
    I wonder if somebody knows: Are they gonna release a new title?? I really enjoyed there games,
    especially Red Alert 2. Thx in advance... Edit: Sorry, I dind't notice, this topic has to be
    in strategy games....sorry, can an admin or mod move this?....
  28. Microsoft Command Shell?
    (0)
    Today, I saw this on winbeta.org : Microsoft Command Shell Beta 1 Released to BetaPlace The code
    name of Microsoft Command Shell is Monad. This shell provide rich scripting support. It built on the
    .NET Framework and fully object-oriented. "It includes many concepts from traditional UNIX shells
    such as bash and ksh, delivers rich scripting support challenging languages like Perl and
    Python"!!!??? /rolleyes.gif' border='0' style='vertical-align:middle'
    alt='rolleyes.gif' /> This Microsoft Command Shell (MSH) can be downloaded here
    http://beta.microso....
  29. Command And Conquer
    best strategy game (11)
    Im surprised noone mentioned C&C yet in the strategy forum! I wont say the series is the best in
    the gaming world, far from that, but in the strategy genre I personally reckon it is. The original
    game had a vivid and solid storyline told by two perspectives, one on each disc, which you can
    either be on the good side or the bad. The FMV sequences is a mixture of real-life people and cgi
    effects. The ingame graphics are good and challenging as they use it against you unabling yourself
    to see anything unless you have your men go over the land which makes more of it visi....
  30. Perl : Help
    How to run command lines (4)
    Hi there , I would like to have help with Perl. When I make a program and I run it , it close
    instantly after it is done. So how could I keep it open after his execution ? And also , where can
    I find Perl command lines ( if it exists for sure ) Thanks everyone , Happy new year. Mathieu_021....

    1. Looking for pause, command, prompt, execution,

Searching Video's for pause, command, prompt, execution,
advertisement




Pause A Command Prompt After Execution?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE