INput from getc 
Author Message
 INput from getc

I am a new programmer amnd I am trying to get a number from a keyboard and
perform a loop based on that number.  However, the prgram keeps converting
the number to the ascii equivalent.  How do I force the variable to stay
with the slected number rather than the ascii equivalent?
Thanks

--



Sat, 16 Feb 2002 03:00:00 GMT  
 INput from getc

   I am a new programmer amnd I am trying to get a number from a keyboard and
   perform a loop based on that number.  However, the prgram keeps converting
   the number to the ascii equivalent.  How do I force the variable to stay
   with the slected number rather than the ascii equivalent?

It doesn't "convert it to the ASCII equivalent."  Everything read from
stdin ("the keyboard") is in text form ("ASCII").  If you need it to
be in another form, such as an integer, you must convert it yourself.
Look up sscanf() and strtol() for some helpful functions for doing
this.
--



Sat, 16 Feb 2002 03:00:00 GMT  
 INput from getc


Quote:
>I am a new programmer amnd I am trying to get a number from a keyboard and
>perform a loop based on that number.  However, the prgram keeps converting
>the number to the ascii equivalent.  How do I force the variable to stay
>with the slected number rather than the ascii equivalent?
>Thanks

Post your code (preferably stripped to the minimum that will exhibit the
problem.

Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
--



Sun, 17 Feb 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. getc(stdin), getting input from the keyboard.

2. getc()

3. Dodgy getc and putc macro definitions

4. Doubt : after getc(ip) how to decrement ip FILE pointer

5. getch vs getchar vs getc

6. Nit-picking: random tags (fortune), getc() etc...

7. getc() prints -1 after 1a

8. Newbie - Difference between getc() and fgetc()

9. getc() and EOF

10. getc/putc vs getchar/putchar (newbie)

11. A question on getc() and EOF

12. ferror() after getc() and fgetc()

 

 
Powered by phpBB® Forum Software