Good day!
I have this problem: I have a number (int) and I want to know who's simbol's ASCII code is.
From letter to number works well:
How should I find the simbol after my int?Code:char s[10];
int i;
for(i=0;i<strlen(s);i++)printf("%d",s[i]);
Printable View
Good day!
I have this problem: I have a number (int) and I want to know who's simbol's ASCII code is.
From letter to number works well:
How should I find the simbol after my int?Code:char s[10];
int i;
for(i=0;i<strlen(s);i++)printf("%d",s[i]);
Assuming it is a single digit number, add it to '0'. The digits '0' through '9' are guaranteed to be in order. That will give you a character and you can get the value of the symbol from that in the same way you did above.
So you have a number, say 65, and you want to see what character that represents? Just print it with %c:Quote:
I have this problem: I have a number (int) and I want to know who's simbol's ASCII code is.
or putchar():Code:printf("%c", 65);
You might want to print a '-' or something if the character isn't printable:Code:putchar(65);
Some characters can't be printed, or won't show up properly if they are.Code:#include <ctype.h> /* for isprint() */
if(isprint(c)) putchar(c);
else putchar('-');
BTW, this is the C++ forum, not the C one.
That realy helped!
10x
P.s.: next time I'll post on the C forum. 10x again.