I've found how to convert a char to its ascii value (toascii) but I want to do it the other way round!

I'm aware you can use putchar() but that doesn't really work so well for what I'm doing, or at least I'd like to find a quicker way if there is one.

Is there not a tochar or basically the opposite of toascii?

Recommended Answers

All 3 Replies

Try the code below

#include <stdio.h>

int main()
{
	int x = 67;
	fprintf(stdout, "c->%c\n", (char)x);
	fprintf(stdout, "c->%c\n", x);
	return 0;
}

What you're asking doesn't make sense.

I'm aware you can use putchar() but that doesn't really work so well for what I'm doing,

Why? Are you trying to output a character and it's outputting a flower? Maybe you need to be more explicit so we can understand what you're doing.

or at least I'd like to find a quicker way if there is one.

Huh? What's quicker than putchar() ?

Is there not a tochar or basically the opposite of toascii?

No, a function like tochar() is worthless.

A char and it's ascii value are identical. It's just two different names for the same numerical value. Like hot dog and wiener.

dear friend it is working good now i can show ASCII VALUES to newcomers in IT.....THANKS A LOT

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.