in C++, how to proceed by pressing just "ENTER"

in C++, how to proceed by pressing just "ENTER"

Page 1 of 1

5 Replies - 12241 Views - Last Post: 28 March 2008 - 07:36 AM Rate Topic: -----

#1 rakitsa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-March 08

in C++, how to proceed by pressing just "ENTER"

Post icon  Posted 28 March 2008 - 04:45 AM

cout<<"to break this PAUSE, press ENTER ";
string tmp;
cin>>string;

this does not work. Why/
Is This A Good Question/Topic? 0
  • +

Replies To: in C++, how to proceed by pressing just "ENTER"

#2 realNoName  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 343
  • Joined: 04-December 06

Re: in C++, how to proceed by pressing just "ENTER"

Posted 28 March 2008 - 05:00 AM

i think the reason it does that is because cin ignores any whitespace characters as input (this includes blank spaces and the newline and tab characters)

if you are looking for a way to pause you can use
cin.get()

Was This Post Helpful? 0
  • +
  • -

#3 Sepanto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 20-March 08

Re: in C++, how to proceed by pressing just "ENTER"

Posted 28 March 2008 - 05:50 AM

i know a code in c which can do it hope it will help you:
char temp[80];//arbitary big size, no real meaning.
do{
gets(temp);
}while(strcmp(temp,"\n")!=0)


Was This Post Helpful? 0
  • +
  • -

#4 MikeRaines  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 78
  • Joined: 30-October 07

Re: in C++, how to proceed by pressing just "ENTER"

Posted 28 March 2008 - 07:08 AM

I beleive the command you are looking for is:

system("pause");

If you are in visual studio this works by default. If you are doing command line stuff I think you need to include <stdio.h> or something to that extent.
Was This Post Helpful? 0
  • +
  • -

#5 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: in C++, how to proceed by pressing just "ENTER"

Posted 28 March 2008 - 07:15 AM

Using the system call to invoke the pause.exe is a platform dependent functionality and does not comply to standards. I'm assuming th goal here is to hold the execution window open....if so, please read the following.

http://www.dreaminco...wtopic30581.htm
Was This Post Helpful? 0
  • +
  • -

#6 Sepanto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 20-March 08

Re: in C++, how to proceed by pressing just "ENTER"

Posted 28 March 2008 - 07:36 AM

As far as i understood what you meant is ONLY when ENTER is pressed to continue,and that's what my loop does. if you meant wait for any input and than continue than there are many ways to do that, adn read the thread amadeus provided the link for.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1