編集の要約なし |
細 文字列「<source」を「<syntaxhighlight」に置換 |
||
| (同じ利用者による、間の3版が非表示) | |||
| 3行目: | 3行目: | ||
isalpha関数は、指定した文字がアルファベット('A' - 'Z', 'a' - 'z')なら真(0以外)を返す関数である。<br> | isalpha関数は、指定した文字がアルファベット('A' - 'Z', 'a' - 'z')なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 24行目: | 24行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 30行目: | 30行目: | ||
C言語で文字がアルファベットの小文字かどうかをチェックするには、ctype.hのislower関数を使用する。<br> | C言語で文字がアルファベットの小文字かどうかをチェックするには、ctype.hのislower関数を使用する。<br> | ||
islower関数は、指定した文字がアルファベットの小文字('a' - 'z')なら真(0以外)を返す関数である。<br> | islower関数は、指定した文字がアルファベットの小文字('a' - 'z')なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 51行目: | 51行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 57行目: | 57行目: | ||
C言語で文字がアルファベットの大文字かどうかをチェックするには、ctype.hのisupper関数を使用する。<br> | C言語で文字がアルファベットの大文字かどうかをチェックするには、ctype.hのisupper関数を使用する。<br> | ||
isupper関数は、指定した文字がアルファベットの大文字('A' - 'Z')なら真(0以外)を返す関数である。<br> | isupper関数は、指定した文字がアルファベットの大文字('A' - 'Z')なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 78行目: | 78行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 84行目: | 84行目: | ||
C言語で文字がアルファベットもしくは数字かどうかをチェックするには、ctype.hのisalnum関数を使用する。<br> | C言語で文字がアルファベットもしくは数字かどうかをチェックするには、ctype.hのisalnum関数を使用する。<br> | ||
isalnum関数は、指定した文字がアルファベットもしくは数字('A' - 'Z', 'a' - 'z', '0' - '9')なら真(0以外)を返す関数である。<br> | isalnum関数は、指定した文字がアルファベットもしくは数字('A' - 'Z', 'a' - 'z', '0' - '9')なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 105行目: | 105行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 111行目: | 111行目: | ||
C言語で文字が10進数の数字かどうかをチェックするには、ctype.hのisdigit関数を使用する。<br> | C言語で文字が10進数の数字かどうかをチェックするには、ctype.hのisdigit関数を使用する。<br> | ||
isdigit関数は、指定した文字が10進数の数字('0' - '9')なら真(0以外)を返す関数である。<br> | isdigit関数は、指定した文字が10進数の数字('0' - '9')なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 132行目: | 132行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 138行目: | 138行目: | ||
C言語で文字が16進数の数字かどうかをチェックするには、ctype.hのisxdigit関数を使用する。<br> | C言語で文字が16進数の数字かどうかをチェックするには、ctype.hのisxdigit関数を使用する。<br> | ||
isxdigit関数は、指定した文字が16進数の数字('0' - '9', 'A' - 'F', 'a' - 'f')なら真(0以外)を返す関数である。<br> | isxdigit関数は、指定した文字が16進数の数字('0' - '9', 'A' - 'F', 'a' - 'f')なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 159行目: | 159行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 166行目: | 166行目: | ||
isspace関数やisblank関数は水平タブなど他の文字も真と判定するため、単に空白かそうでないかを判定する場合は、<br> | isspace関数やisblank関数は水平タブなど他の文字も真と判定するため、単に空白かそうでないかを判定する場合は、<br> | ||
これらの関数は使用しない方が無難である。<br> | これらの関数は使用しない方が無難である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 191行目: | 191行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 197行目: | 197行目: | ||
C言語で文字が表示文字かどうかをチェックするには、ctype.hのisprint関数を使用する。<br> | C言語で文字が表示文字かどうかをチェックするには、ctype.hのisprint関数を使用する。<br> | ||
isprint関数は、指定した文字が表示文字なら真(0以外)を返す関数である。<br> | isprint関数は、指定した文字が表示文字なら真(0以外)を返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 222行目: | 222行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 228行目: | 228行目: | ||
C言語で文字が制御文字かどうかをチェックするには、ctype.hのiscntrl関数を使用する。 | C言語で文字が制御文字かどうかをチェックするには、ctype.hのiscntrl関数を使用する。 | ||
iscntrl関数は、指定した文字が制御文字なら真(0以外)を返す関数である。 | iscntrl関数は、指定した文字が制御文字なら真(0以外)を返す関数である。 | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 253行目: | 253行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 259行目: | 259行目: | ||
C言語でアルファベットの大文字を小文字に変換するには、ctype.hのtolower関数を使用する。<br> | C言語でアルファベットの大文字を小文字に変換するには、ctype.hのtolower関数を使用する。<br> | ||
tolower関数は指定したint型の文字を小文字に変換して返す関数である。<br> | tolower関数は指定したint型の文字を小文字に変換して返す関数である。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 274行目: | 274行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
| 280行目: | 280行目: | ||
C言語でアルファベットの小文字を大文字に変換するには、ctype.hのtoupper関数を使用する。<br> | C言語でアルファベットの小文字を大文字に変換するには、ctype.hのtoupper関数を使用する。<br> | ||
toupper関数は指定したint型の文字を大文字に変換して返す。<br> | toupper関数は指定したint型の文字を大文字に変換して返す。<br> | ||
< | <syntaxhighlight lang="c++"> | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
| 295行目: | 295行目: | ||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<br><br> | <br><br> | ||
__FORCETOC__ | __FORCETOC__ | ||
[[カテゴリ:C]] | [[カテゴリ:C]] | ||