Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I get the numeric value corresponding to a character? ....
How can I get the numeric value (i.e. ASCII or other character set code) corresponding to a character, or vice versa?
✍: Guest
In C, characters are represented by small integers corresponding to their values in the machine's character set. Therefore, you don't need a conversion function: if you have the character, you have its value. The following fragment:
int c1 = 'A', c2 = 65;
printf("%c %d %c %d\n", c1, c1, c2, c2);
prints
A 65 A 65
on an ASCII machine.
To convert back and forth between the digit characters and the corresponding integers in the range 0-9, add or subtract the constant '0' (that is, the character value '0').
2016-03-07, 1236👍, 0💬
Popular Posts:
What Is a TD Tag/Element? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells A "td" elemen...
How To List All Values of Submitted Fields? - PHP Script Tips - Processing Web Forms If you want lis...
What is the difference between strings and character arrays? A major difference is: string will have...
How can you implement MVC pattern in ASP.NET? The main purpose using MVC pattern is to decouple the ...
How To Empty Your Recycle Bin? - Oracle DBA FAQ - Managing Oracle Database Tables If your recycle bi...