|
-
Sep 13th, 2001, 07:30 PM
#1
Thread Starter
Addicted Member
overflowing a char
Simple one I think...
I am reading data in from the keyboard and at one point I want the user to input a single char, now if the user provides "AAA" instead of just 'A' the second and third A gets pushed into the next variable when I try and read it in Any idea how to just drop off the extra junk after the first letter?
I have tried cin.ignore() but that will only chop off one character...
-
Sep 13th, 2001, 07:41 PM
#2
did you try the getchar() function? It only allows one character to be inputted.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 13th, 2001, 07:59 PM
#3
Fanatic Member
Hey crptc, can you explain something to me? What's the difference between getch() and getchar()?
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 13th, 2001, 09:06 PM
#4
One is defined in conio.h, the other is defined in stdio.h. There are probably other differences, but nothing major.
Z.
-
Sep 14th, 2001, 05:19 AM
#5
Monday Morning Lunatic
If in doubt, use the one from stdio.h
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|