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]);
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: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.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
That realy helped!
10x
P.s.: next time I'll post on the C forum. 10x again.