Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > getchar() question

Reply
Thread Tools

getchar() question

 
 
Bill Cunningham
Guest
Posts: n/a
 
      01-07-2011
I have this little code that complies fine and I guess it does what it's
written to do. Trouble is I want the system to exit by pressing any key not
just enter. Would this have something to do with what the int a has stored
and what getchar() will return? Then I want to move on with my idea. Please
excuse the system specific numbers passed to exit().

Bill


 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      01-07-2011
"Bill Cunningham" wrote:

> I have this little code that complies fine and I guess it does what
> it's written to do. Trouble is I want the system to exit by pressing any
> key not just enter. Would this have something to do with what the int a
> has stored and what getchar() will return? Then I want to move on with my
> idea. Please excuse the system specific numbers passed to exit().


Search Google Groups for getch.


 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a
 
      01-07-2011
On January 7, 2011 12:59, in comp.lang.c, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> "Bill Cunningham" wrote:
>
>> I have this little code that complies fine and I guess it does what
>> it's written to do. Trouble is I want the system to exit by pressing any
>> key not just enter. Would this have something to do with what the int a
>> has stored and what getchar() will return? Then I want to move on with my
>> idea. Please excuse the system specific numbers passed to exit().

>
> Search Google Groups for getch.


How would the curses getch() function help him?

--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------


 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      01-07-2011
On Jan 7, 7:36*pm, "Bill Cunningham" <(E-Mail Removed)> wrote:
> * * I have this little code that complies fine and I guess it does what it's
> written to do. Trouble is I want the system to exit by pressing any key not
> just enter. Would this have something to do with what the int a has stored
> and what getchar() will return? Then I want to move on with my idea. Please
> excuse the system specific numbers passed to exit().
>

You need to use a non-standard library function. It's years since I
did any command window programming with such a library, but usually
the function is called kbhit().


 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      01-07-2011
On 2011-01-07, Malcolm McLean <(E-Mail Removed)> wrote:
> On Jan 7, 7:36?pm, "Bill Cunningham" <(E-Mail Removed)> wrote:
>> ? ? I have this little code that complies fine and I guess it does what it's
>> written to do. Trouble is I want the system to exit by pressing any key not
>> just enter. Would this have something to do with what the int a has stored
>> and what getchar() will return? Then I want to move on with my idea. Please
>> excuse the system specific numbers passed to exit().


> You need to use a non-standard library function.


Quite right.

> It's years since I
> did any command window programming with such a library, but usually
> the function is called kbhit().


"Usually"?

Wouldn't that imply that, out of the more than a dozen such ways of doing
this, more than one had named the function that? I've only seen one target
that had a "kbhit()".

I also can't understand why anyone still responds to "Bill Cunningham". He's
a troll who posts elaborately designed stuff which it is impossible for
someone to have gotten wrong that way; in order to make these mistakes, you'd
need to know enough not to make them. He's been pretending to be stuck
at the "first week of C programming experience" for several years, and
frankly, I think around the time he announced that he was planning on writing
a new database system faster and more robust than Oracle, but couldn't figure
out how to store strings in a file, people shoulda caught on.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / (E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      01-07-2011
"Lew Pitcher" wrote:

> On January 7, 2011 12:59, in comp.lang.c, (E-Mail Removed) wrote:
>
>> "Bill Cunningham" wrote:
>>
>>> I have this little code that complies fine and I guess it does what
>>> it's written to do. Trouble is I want the system to exit by pressing any
>>> key not just enter. Would this have something to do with what the int a
>>> has stored and what getchar() will return? Then I want to move on with
>>> my
>>> idea. Please excuse the system specific numbers passed to exit().

>>
>> Search Google Groups for getch.

>
> How would the curses getch() function help him?


Well, darn, I guess it wouldn't. It is the first thing that comes into my
mind when this general subject is mentioned. It has been a while since I
have done any of this stuff. I guess he wants kbhit as someone else has
already mentioned.
---
Sorry Bill, look for kbhit on Google Groups. And note that curses is Unix
speak. The DOS/Windows equivalent is conio.h.


 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      01-07-2011
On 01/ 8/11 07:03 AM, Richard wrote:
> "Bill Cunningham"<(E-Mail Removed)> writes:
>
>> I have this little code that complies fine and I guess it does what it's
>> written to do. Trouble is I want the system to exit by pressing any key not
>> just enter. Would this have something to do with what the int a has stored
>> and what getchar() will return? Then I want to move on with my idea. Please
>> excuse the system specific numbers passed to exit().

>
> 9/10!


9? I'd give it a 6 a best.

--
Ian Collins
 
Reply With Quote
 
David Resnick
Guest
Posts: n/a
 
      01-07-2011
On Jan 7, 2:42*pm, Ian Collins <(E-Mail Removed)> wrote:
> On 01/ 8/11 07:03 AM, Richard wrote:
>
> > "Bill Cunningham"<(E-Mail Removed)> *writes:

>
> >> * * *I have this little code that complies fine and I guess it does what it's
> >> written to do. Trouble is I want the system to exit by pressing any key not
> >> just enter. Would this have something to do with what the int a has stored
> >> and what getchar() will return? Then I want to move on with my idea. Please
> >> excuse the system specific numbers passed to exit().

>
> > 9/10!

>
> 9? *I'd give it a 6 a best.


I'd have to agree 9 is too high. So is 6. Compared to some of the
past gems he has written, this is quite low on the list. The ones
that show C code are surely much more worthy of a high rank, as are
the ones that mention IPC or databases or grand projects.

-David

 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      01-07-2011
On 2011-01-07, osmium <(E-Mail Removed)> wrote:
> Well, darn, I guess it wouldn't. It is the first thing that comes into my
> mind when this general subject is mentioned. It has been a while since I
> have done any of this stuff. I guess he wants kbhit as someone else has
> already mentioned.


Uh, maybe.

> Sorry Bill, look for kbhit on Google Groups. And note that curses is Unix
> speak. The DOS/Windows equivalent is conio.h.


Yeah, uhm.

It's entirely possible that the OP isn't primarily looking for a DOS interface
that was obsolete ten years ago. It's also entirely possible that the OP
isn't looking for curses.

Lew's point was that your answer was simultaneously off-topic and most likely
wrong. You appear to be sort of having trouble with this.

The real answer to that question, if it were asked by a non-troll, would
probably be to start by jumping back and asking why you think you want to
do that. The chances that anything from <conio.h> would be the right
choice, or even make an appearance in a top-ten list of plausible right
choices, are basically nil. The answer to any question posted by "Bill
Cunningham" is to stop feeding the trolls.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / (E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      01-07-2011
"Bill Cunningham" <(E-Mail Removed)> writes:
> I have this little code that complies fine and I guess it does what it's
> written to do. Trouble is I want the system to exit by pressing any key not
> just enter. Would this have something to do with what the int a has stored
> and what getchar() will return? Then I want to move on with my idea. Please
> excuse the system specific numbers passed to exit().


In other words:

How can I read a single character from the keyboard without waiting for
the RETURN key? How can I stop characters from being echoed on the
screen as they're typed?

<http://www.c-faq.com/>, question 19.1.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments