Results 1 to 4 of 4

Thread: converting ASCII code to character

  1. #1

    Thread Starter
    Addicted Member jmiller's Avatar
    Join Date
    Jul 2002
    Location
    University of Michigan
    Posts
    238

    converting ASCII code to character

    how do you convert ascii character code to a character, say like in a cout statement.

  2. #2
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    cast it to a char

    (char)<ascii code>


    Of course this works only for 0-255 (or actually since it's signed it should be -128 to 127)

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    char should usually be an unsigned quantity, since a negative character code doesn't mean anything.
    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

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    But it isn't always.

    What do you mean by "converting an ASCII code to a character"? The computer makes no distinction between an ASCII code and the appropriate character. It's all about how you output it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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