This shows you the differences between two versions of the page.
cpp:cctype:isascii [2012/10/12 15:03] |
cpp:cctype:isascii [2024/02/16 01:04] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ====== isascii ===== | ||
+ | <code cpp> | ||
+ | int isascii(int char); | ||
+ | </code> | ||
+ | |||
+ | a macro that tests if a char a ASCII char (0-127) is | ||
+ | ===== cpp Sourcecode Example ===== | ||
+ | <code cpp> | ||
+ | /* | ||
+ | * isascii example code | ||
+ | * http://code-reference.com/cpp/cctype/isascii | ||
+ | */ | ||
+ | #include <iostream> /* including standard library */ | ||
+ | #include <string> | ||
+ | #include <cctype> | ||
+ | |||
+ | using namespace std; | ||
+ | int main ( void ) | ||
+ | { | ||
+ | int i; | ||
+ | string str="Test ÖÄ%1"; | ||
+ | for (i=0; i <= 11;i++) | ||
+ | { | ||
+ | if ( isascii(str) != 0 ) | ||
+ | { | ||
+ | cout << "character" << i << " isascii" << endl; | ||
+ | } | ||
+ | } | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | </code> | ||
+ | ==== output ==== | ||
+ | output: | ||
+ | character 0 isascii | ||
+ | character 1 isascii | ||
+ | character 2 isascii | ||
+ | character 3 isascii | ||
+ | character 4 isascii | ||
+ | character 9 isascii | ||
+ | character 10 isascii | ||
+ | character 11 isascii | ||