• C

convert binary to equivalent ascii char

is there a function in C that converts binary to ascii characters?
LVL 2
pesstAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

C_DreamerCommented:
Not as such. C does not require that the host environment use ASCII, and there is no specific function catering for ASCII. If you have an ASCII system, there is no need to do any conversion. For example, the ASCII code for 'A' is 65, and this program shows that there is no need for any conversion function.

#include <stdio.h>

int main(void)
{
int ascii = 65; /* in binary, that's 01000001, but of course, it makes no difference here */
char character;

character = ascii; /* simple assignment */

printf("%d\n", ascii);
printf("%c\n", character);
return 0;
}

As you can see, it just depends how you look at it.

If, on the other hand, your collating sequence is NOT ASCII, then the answer is still no, and the above won't work (that is, it won't give you 'A', although it /will/ give you the correct interpretation of 65 on that system).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
=
0
pesstAuthor Commented:
Not the answer I was looking for:)
thanks
0
C_DreamerCommented:
Then you need to specify more clearly what you want. For example, if you want to turn this string: "0100000101000010" into this string: "AB", then it's fairly easy. But it might still not be what you mean, as your question didn't even mention strings.

Please be more precise if you want a useful answer.


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.