Solved

number->ASCII byte

Posted on 1998-07-01
7
186 Views
Last Modified: 2013-11-20
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
Comment
Question by:zorker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 2

Accepted Solution

by:
kinkajou earned 20 total points
ID: 1318589
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
 

Author Comment

by:zorker
ID: 1318590
I used ch=15 and got a little * like character.
The musical note was 14.
Did I do something wrong?
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1318591
Opps, my bad, you got the right character for 15!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zorker
ID: 1318592
I used ch=15 and got a little * like character.
The musical note was 14.
Did I do something wrong?
0
 

Author Comment

by:zorker
ID: 1318593
Thanks.
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1318594
Your welcome and Good Luck!
0
 

Author Comment

by:zorker
ID: 1318595
Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question