• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

convert binary to equivalent ascii char

is there a function in C that converts binary to ascii characters?
  • 2
1 Solution
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).
pesstAuthor Commented:
Not the answer I was looking for:)
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.


Featured Post

Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

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