Inputs?

is there way to allow the user to input w/ou hitting enter?

Page 1 of 1

5 Replies - 1235 Views - Last Post: 05 January 2002 - 10:46 AM Rate Topic: -----

#1 DestroyerOfWorlds  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 55
  • Joined: 11-October 01

Inputs?

Posted 11 November 2001 - 09:49 PM

I'm looking for a way to accept a single character from the used with out them having to hit enter. I know it's possible but I wandering if anyone knew how to do it. even if you just point me in he right direction.
Is This A Good Question/Topic? 0
  • +

Replies To: Inputs?

#2 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4496
  • View blog
  • Posts: 28,404
  • Joined: 21-March 01

Re: Inputs?

Posted 12 November 2001 - 04:47 PM

well, i can get it so all you have to do is just hit enter, no 1 followed by enter or anything like that, but with my messing around, thats all ive been able to do. here it is to press enter

cout << "Press enter to continue
";
cin.get (pause, 1);
cin.ignore(80,'
');

sorry, maybe someone else might know the how to do what you want

Was This Post Helpful? 0
  • +
  • -

#3 Null and Void  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 204
  • Joined: 29-April 01

Re: Inputs?

Posted 12 November 2001 - 04:59 PM

It is OS dependent, and sometimes compiler dependent. The POSIX standard (the standard most unixes comply with) has methods of setting the input stream to nonblocking, et cetera. MSVC and Borland both have a NON-STANDARD function called 'getch' (defined in conio.h) which returns the ASCII value of the last key hit, or waits for a single key to be pressed. They both should also have 'kbhit', which allows you to check if any keys are being held down.
Was This Post Helpful? 0
  • +
  • -

#4 Kenshin Rules  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 04-January 02

Re: Inputs?

Posted 05 January 2002 - 12:48 AM

SuperSloth: What does pause do and where is it from. I tried to run that becuase I was interested in it as well. Is it in a certain library.
Was This Post Helpful? 0
  • +
  • -

#5 blutrane  Icon User is offline

  • 私もクールです

Reputation: 25
  • View blog
  • Posts: 1,934
  • Joined: 17-May 01

Re: Inputs?

Posted 05 January 2002 - 07:46 AM

actually no its not. its regular code; you should already have the header file

pause works the same a cin does. it waits for the user to press enter to continue


and i might add that system("pause"); works just as well i believe you only need stdlib.h for that

(Edited by blutrane at 7:48 am on Jan. 5, 2002)

Was This Post Helpful? 0
  • +
  • -

#6 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: Inputs?

Posted 05 January 2002 - 10:46 AM

can you say getchar

i can

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1