Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

number->ASCII byte

I want to get the ASCII byte for the #15 and for #0, but I can't type 'em in.  How do I cast?
is it (char)15 and (char)0?
0
zorker
Asked:
zorker
  • 4
  • 3
1 Solution
 
kinkajouCommented:
I'm not sure what you will get with your type cast as specified above.

Depending on what you need to do with the characters ASCII 15 and 0, you may not need to type cast.

Can you just assign the value like:
char string[1];
string[0] = 15;?
so that printf ("%s", string); prints a 0xD char that looks like a musical note.

Or are you asking to convert a number to a string like so:
char string[2];
string[0] = '1';
string[1] = '5';
so that printf ("%s", string); prints "15"
Which it might be better to use itoa();
0
 
zorkerAuthor Commented:
I used ch=15 and got a little * like character.
The musical note was 14.
Did I do something wrong?
0
 
kinkajouCommented:
Opps, my bad, you got the right character for 15!
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
zorkerAuthor Commented:
I used ch=15 and got a little * like character.
The musical note was 14.
Did I do something wrong?
0
 
zorkerAuthor Commented:
Thanks.
0
 
kinkajouCommented:
Your welcome and Good Luck!
0
 
zorkerAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now