This shows you the differences between two versions of the page.
cpp:cctype:toascii [2012/10/12 15:03] |
cpp:cctype:toascii [2024/02/16 01:04] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ===== toascii ===== | ||
+ | <code cpp> | ||
+ | int toascii (int c); | ||
+ | </code> | ||
+ | a macro thats convert **c** into ascii chars | ||
+ | |||
+ | ===== cpp Sourcecode Example ===== | ||
+ | <code cpp> | ||
+ | #include <iostream> /* including standard library */ | ||
+ | #include <cctype> | ||
+ | |||
+ | using namespace std; | ||
+ | int main( void ) | ||
+ | { | ||
+ | int i; | ||
+ | for (i=0x2a; i<=0x42; i++) { | ||
+ | cout << i << " is " << static_cast<char>(toascii(i)) << endl; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | </code> | ||
+ | ==== output ==== | ||
+ | output | ||
+ | 0x2a is * | ||
+ | 0x2b is + | ||
+ | 0x2c is , | ||
+ | 0x2d is - | ||
+ | 0x2e is . | ||
+ | 0x2f is / | ||
+ | 0x30 is 0 | ||
+ | 0x31 is 1 | ||
+ | 0x32 is 2 | ||
+ | 0x33 is 3 | ||
+ | and so on, and so on | ||