• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting an INT to a CHAR ?

 
Kristian Andersson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to find out what ASCII-numbers are equalent to the letters:
"c", "o", "m". Perhaps not the easiest way, but I set up this code:

I knew it wouldn't work. Somehow, I need to convert the int to a char, or whatever. Almost like the Integer-thing, but not quite. (And yes, I don't know the exact words or terms for "it". If anyone wants to explain it to me - go ahead.)
And by the way. If it would've worked, then I would've counted every printout on the screen until I stumbled upon the desired letters.
[ May 10, 2004: Message edited by: Kristian Andersson ]
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code is fine as it is, you just need to explicitly cast the int to a char (Since an int is larger than a char, the compiler thinks that you made a mistake. Explicit casts are ways of telling the compiler "I know what I'm doing ... I think )

BTW, the last series of lines will do what you are looking for without having to search the printout.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to find out what ASCII-numbers are equalent to the letters:
"c", "o", "m".

If you're not necessarily looking for a code-based solution, I frequently peek at asciitable.com for ascii character info.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic