Results 1 to 5 of 5

Thread: overflowing a char

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183

    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...

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  3. #3
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Hey crptc, can you explain something to me? What's the difference between getch() and getchar()?
    Alcohol & calculus don't mix.
    Never drink & derive.

  4. #4
    Zaei
    Guest
    One is defined in conio.h, the other is defined in stdio.h. There are probably other differences, but nothing major.

    Z.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width