Press Any Key to Continue C Without Me Coding That

Press any key to continue...

 Press any key to continue...

Author Message

 Press any key to continue...

I need to implement the common phrase "Press any key to continue..."
Can anyone give me a clue on what C functions I could use that don't
require a carriage return (I don't care what key is pressed).  Or is
their a way to generate a system call when a key is pressed.

Thanks In Advance
Andrew Watts

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

I just do something along the lines of what is listed below.  I believe
that's what you're talking about.

// Let's slow things down
printf("\nPlease press Return!");
getchar();

--

Tim Astle

Quote:

> I need to implement the common phrase "Press any key to continue..."
> Can anyone give me a clue on what C functions I could use that don't
> require a carriage return (I don't care what key is pressed).  Or is
> their a way to generate a system call when a key is pressed.

> Thanks In Advance
> Andrew Watts

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:

> I need to implement the common phrase "Press any key to continue..."
> Can anyone give me a clue on what C functions I could use that don't
> require a carriage return (I don't care what key is pressed).  Or is
> their a way to generate a system call when a key is pressed.

no, you'll have to use non-standard functions to do this.  btw this question
was asked just a few days ago; you might want to check for previously asked
questions before asking your own.

--
/"\                              m i k e    b u r r e l l

               X        AGAINST HTML MAIL
/ \

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Oops!  You didn't want a return.  Sorry.

Ignore my post :-)

--

Tim Astle

Quote:

> I just do something along the lines of what is listed below.  I believe
> that's what you're talking about.

> // Let's slow things down
> printf("\nPlease press Return!");
> getchar();

> --

> Tim Astle

> > I need to implement the common phrase "Press any key to continue..."
> > Can anyone give me a clue on what C functions I could use that don't
> > require a carriage return (I don't care what key is pressed).  Or is
> > their a way to generate a system call when a key is pressed.

> > Thanks In Advance
> > Andrew Watts

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:

>I need to implement the common phrase "Press any key to continue..."
>Can anyone give me a clue on what C functions I could use that don't
>require a carriage return (I don't care what key is pressed).  Or is
>their a way to generate a system call when a key is pressed.

It's not ANSI C but, in DOS compatible land, the non-ANSI function
is _kbhit(). For Win32 Console, it's (by example):

PeekConsoleInput(s_hConIn, &peek, 1, &peekRecordsRead);

if (peekRecordsRead && (peek.EventType & KEY_EVENT))
{
switch (tolower(peek.Event.KeyEvent.wVirtualScanCode))
{ blah blah blah }

Quote:

}

- Mark A. Odell (remove thisisnotvalid. to reply via email)

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

That won't work because it really needs to be "any" key.

Quote:

> I just do something along the lines of what is listed below.  I believe
> that's what you're talking about.

> // Let's slow things down
> printf("\nPlease press Return!");
> getchar();

> --

> Tim Astle

> > I need to implement the common phrase "Press any key to continue..."
> > Can anyone give me a clue on what C functions I could use that don't
> > require a carriage return (I don't care what key is pressed).  Or is
> > their a way to generate a system call when a key is pressed.

> > Thanks In Advance
> > Andrew Watts

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

: I need to implement the common phrase "Press any key to continue..."
: Can anyone give me a clue on what C functions I could use that don't
: require a carriage return (I don't care what key is pressed).  Or is
: their a way to generate a system call when a key is pressed.

This is a FAQ. Short answer: Not portable. Ask in your own system's
newsgroup.

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ |
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/

"Show me a good mouser and I'll show you a cat with bad breath."
- Garfield

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:

>>I need to implement the common phrase "Press any key to continue..."
>>Can anyone give me a clue on what C functions I could use that don't
>>require a carriage return (I don't care what key is pressed).  Or is
>>their a way to generate a system call when a key is pressed.

>It's not ANSI C but, in DOS compatible land, the non-ANSI function
>is _kbhit().

[snip rest of OT code]

<OT>
The (DOS, BC or MSC) kbhit() function does not respond to _any_ key. It does
not 'see' SHIFT, CTRL, ALT, F11, F12 and some other 'special' keys. To make
a program respond to any key is not that easy and requires stuff even less
portable than kbhit() (bios int16h, or even an interrupt handler, depending
on your definition  of any). And even then: (actual stuffy-old helpdesk
call) Luser calls helpdesk and ask where the ANY-key is on the keyboard.
</OT>

Stef

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:


> I need to implement the common phrase "Press any key to continue..."
> Can anyone give me a clue on what C functions I could use that don't
> require a carriage return (I don't care what key is pressed).  Or is
> their a way to generate a system call when a key is pressed.

Why not implement the common phrase "Press enter to continue...".
Then you can actually do this without resorting to non-standard
non-portable implementation-specific functionality.

--

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:


> That won't work because it really needs to be "any" key.

Why?
And you should note that the common DOS/WinBloze "press any key..." is a
lie.  There are a lot of keys on most keyboards for which it does not
work.

--

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

: >
: >I need to implement the common phrase "Press any key to continue..."
: >Can anyone give me a clue on what C functions I could use that don't
: >require a carriage return (I don't care what key is pressed).  Or is
: >their a way to generate a system call when a key is pressed.

: It's not ANSI C but, in DOS compatible land, the non-ANSI function
: is _kbhit(). For Win32 Console, it's (by example):

What makes you think the OP is working on a DOS platform?  He may just as
easily be working on Unix or a Unix-workalike OS like Linux or FreeBSD.
To give a poster the best chance of getting an accurate, useful answer,
it is best to refer to a newsgroup which reflects the OP's development
environment.  In this case, the OP didn't specify the platform, so the
next logical step would be to ask.  The OP could also read the FAQ,
particularly question 19.1.

Paul

--
Paul D. Boyle

North Carolina State University
http://laue.chem.ncsu.edu/web/xray.welcome.html

Sun, 06 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:

> > That won't work because it really needs to be "any" key.

> Why?
> And you should note that the common DOS/WinBloze "press any key..." is a
> lie.  There are a lot of keys on most keyboards for which it does not
> work.

Quite so. A few years ago I wrote a grossly non-portable Game of Life
program, in which the aim was to use no standard library functions,
implementation library functions, or anything at all except raw C
syntax. In effect, I was pretending that my C compiler was a
freestanding implementation with no standard library and no inline
assembler.

To quit the program, the user had to press the very keys which usually
don't work as 'any' keys: Scroll Lock, Shift, Ctrl, Num Lock, etc.

Since I had the terrible gall to post such an offensively
platform-specific program in these hallowed halls, the OP may find a
Deja search to be of some use, as may that other fellow looking for a
Game of Life source.

The only bit of that program that I'm desperately ashamed of is the
PRNG, which seems to glory in undefined behaviour. Oopsie. A little
research into PRNGs on my part would have prevented the 'need' for it.

--

Richard Heathfield

"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.

C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
30 K&R Answers: http://users.powernet.co.uk/eton/kandr2/index.html (67
to go)

Mon, 07 Oct 2002 03:00:00 GMT

 Press any key to continue...

Quote:

>> I need to implement the common phrase "Press any key to continue..."
>> Can anyone give me a clue on what C functions I could use that don't
>> require a carriage return (I don't care what key is pressed).  Or is
>> their a way to generate a system call when a key is pressed.

>no, you'll have to use non-standard functions to do this.  btw this question
>was asked just a few days ago; you might want to check for previously asked
>questions before asking your own.

People, why can't we be a little more friendly here? Everyone is so
HASTY in getting oin someone's face about ITS IN THE FAQ, IT WAS JUST
POSTED, LOOK BEFORE ASKING.. What is all this crap. For your (SOME OF
YOU) information, some people are NEW to this group and there
ISP/NewsGroups Server MAY not have this online anymore.

EITHER Answer the question asked, or SHUT UP! If the reason you want
people to look in the FAQ and History to "SAVE BANDWIDTH" or whatever
it is, then QUIT posting 1000's of replies telling them of the FAQ.
ONE answer they are looking for is a LOT less than all the stupid look
here look there replies.  THIS IS SUPPOSED TO BE A HELP AREA! HELP,
DONT FLAME PEOPLE! GEEEeeez.

An OPINION I felt had to be presented!

Mon, 07 Oct 2002 03:00:00 GMT

 Press any key to continue...

in comp.lang.c:

Quote:


> >> I need to implement the common phrase "Press any key to continue..."
> >> Can anyone give me a clue on what C functions I could use that don't
> >> require a carriage return (I don't care what key is pressed).  Or is
> >> their a way to generate a system call when a key is pressed.

> >no, you'll have to use non-standard functions to do this.  btw this question
> >was asked just a few days ago; you might want to check for previously asked
> >questions before asking your own.

> People, why can't we be a little more friendly here? Everyone is so
> HASTY in getting oin someone's face about ITS IN THE FAQ, IT WAS JUST
> POSTED, LOOK BEFORE ASKING.. What is all this crap. For your (SOME OF
> YOU) information, some people are NEW to this group and there
> ISP/NewsGroups Server MAY not have this online anymore.

> EITHER Answer the question asked, or SHUT UP! If the reason you want
> people to look in the FAQ and History to "SAVE BANDWIDTH" or whatever
> it is, then QUIT posting 1000's of replies telling them of the FAQ.
> ONE answer they are looking for is a LOT less than all the stupid look
> here look there replies.  THIS IS SUPPOSED TO BE A HELP AREA! HELP,
> DONT FLAME PEOPLE! GEEEeeez.

> An OPINION I felt had to be presented!

This is an unmoderated newsgroup and you are entitled to your opinion
no matter how wrong it is.

Jack Klein
--
Home: http://jackklein.home.att.net

Mon, 07 Oct 2002 03:00:00 GMT

 Press any key to continue...

Stef a crit dans le message

Quote:

><OT>
>The (DOS, BC or MSC) kbhit() function does not respond to _any_ key. It
does
>not 'see' SHIFT, CTRL, ALT, F11, F12 and some other 'special' keys. To make
>a program respond to any key is not that easy and requires stuff even less
>portable than kbhit() (bios int16h, or even an interrupt handler, depending
>on your definition  of any). And even then: (actual stuffy-old helpdesk
>call) Luser calls helpdesk and ask where the ANY-key is on the keyboard.

Come on, just call getch(), and once again in the previous returned 0...  It
is not that difficult.

Quote:

></OT>

--
-hs- "Stove"
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
"Really?  When run on my machine, a printed copy of the C FAQ leaps
from the monitor and whacks me over the head.." -- Chris Mears CLC

Mon, 07 Oct 2002 03:00:00 GMT
 [ 25 post ] Go to page: [1] [2]

villarrealhingive.blogspot.com

Source: http://computer-programming-forum.com/47-c-language/f6cfc7d2bc3865aa.htm

0 Response to "Press Any Key to Continue C Without Me Coding That"

ارسال یک نظر

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel