「C言語/標準ライブラリ/ctype.h」の版間の差分

削除された内容 追加された内容
preタグをsourceタグに修正
Ef3 (トーク | 投稿記録)
DL化
タグ: 2017年版ソースエディター
47 行
 
=== isalnum関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isalnum(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが英数字('A'~'Z', 'a'~'z', '0'~'9')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
67 行
int c;
printf("文字を入力してください:");
int c = getchar();
if (isalnum(c))
printf("%cは英数字です。", c);
else
74 行
}
</syntaxhighlight>
</source>
 
=== isalpha関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isalpha(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが英文字('A'~'Z', 'a'~'z')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
97 行
int c;
printf("文字を入力してください:");
int c = getchar();
if (isalpha(c))
printf("%cは英文字です。", c);
else
104 行
}
 
</source>
 
=== isblank関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isblank(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが標準ブランク文字(' ', "\t")の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
125 行
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
if (isblank(c))
printf("%cは標準ブランク文字です。", c);
else
134 ⟶ 133行目:
}
</syntaxhighlight>
</source>
 
=== iscntrl関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int iscntrl(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが制御文字(0x00~0x1f, 0x7f)の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
157 ⟶ 156行目:
int c;
printf("文字を入力してください:");
int c = getchar();
if (isctrl(c))
printf("%cは制御文字です。", c);
else
164 ⟶ 163行目:
}
</syntaxhighlight>
</source>
 
=== isdigit関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isdigit(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが数字('0'~'9')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
185 ⟶ 184行目:
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
if (isdigit(c))
printf("%cは数字です。", c);
else
194 ⟶ 192行目:
}
</syntaxhighlight>
</source>
 
=== isgraph関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isgraph(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが空白(' ')を除く表示文字(0x21~0x7e)の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
217 ⟶ 215行目:
int c;
printf("文字を入力してください:");
int c = getchar();
if (isgraph(c))
printf("%cは表示文字(空白を除く)です。", c);
else
224 ⟶ 222行目:
}
</syntaxhighlight>
</source>
 
=== islower関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int islower(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが英小文字('a'~'z')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
247 ⟶ 245行目:
int c;
printf("文字を入力してください:");
int c = getchar();
if (islower(c))
printf("%cは英小文字です。", c);
else
254 ⟶ 252行目:
}
</syntaxhighlight>
</source>
 
=== isprint関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isprint(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが空白(' ')を含む表示文字(0x20~0x7e)の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
275 ⟶ 273行目:
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
if (isprint(c))
printf("%cは表示文字(空白を含む)です。", c);
else
284 ⟶ 281行目:
}
</syntaxhighlight>
</source>
 
=== ispunct関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int ispunct(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが区切り文字(0x21~0x2f, 0x3a~0x40, 0x5b~0x60, 0x7b~0x7e)の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
307 ⟶ 304行目:
int c;
printf("文字を入力してください:");
int c = getchar();
if (ispunct(c))
printf("%cは区切り文字です。", c);
else
314 ⟶ 311行目:
}
</syntaxhighlight>
</source>
 
=== isspace関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isspace(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが標準空白類文字(' ', '\f', '\n', '\r', '\t', '\v')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
337 ⟶ 334行目:
int c;
printf("文字を入力してください:");
int c = getchar();
if (isspace(c))
printf("%cは標準空白類文字です。", c);
else
344 ⟶ 341行目:
}
</syntaxhighlight>
</source>
 
=== isupper関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isupper(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが英大文字('A'~'Z')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
365 ⟶ 362行目:
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
if (isupper(c))
printf("%cは英大文字です。", c);
else
374 ⟶ 370行目:
}
</syntaxhighlight>
</source>
 
=== isxdigit関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int isxdigit(int c);
</syntaxhighlight>
</source>
*; 引数
:c 判定する文字
*; 返却値
:判定の結果
*; 機能
:文字cが16進数字('0'~'9', 'A'~'F', 'a'~'f')の場合真(0以外の値)を返し、それ以外の場合偽(0)を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
395 ⟶ 391行目:
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
if (isxdigit(c))
printf("%cは16進数字です。", c);
else
404 ⟶ 399行目:
}
</syntaxhighlight>
</source>
 
== 大文字小文字変換関数 ==
410 ⟶ 405行目:
 
=== tolower関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int tolower(int c);
</syntaxhighlight>
</source>
*; 引数
:c 変換する文字
*; 返却値
:変換の結果の文字
*; 機能
:文字cが大文字の場合、小文字に変換した値を返す。文字cが大文字以外の場合、変換せずにそのままの値を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
428 ⟶ 423行目:
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
printf("%cは小文字にすると%cです。", c, tolower(c));
}
</syntaxhighlight>
</source>
 
=== toupper関数 ===
*; 形式
: <sourcesyntaxhighlight lang=c>
#include <ctype.h>
int toupper(int c);
</syntaxhighlight>
</source>
*; 引数
:c 変換する文字
*; 返却値
:変換の結果の文字
*; 機能
:文字cが小文字の場合、大文字に変換した値を返す。文字cが小文字以外の場合、変換せずにそのままの値を返す。
*;
: <sourcesyntaxhighlight lang=c>
#include <stdio.h>
#include <ctype.h>
454 ⟶ 448行目:
int main(void)
{
int c;
printf("文字を入力してください:");
int c = getchar();
printf("%cは大文字にすると%cです。", c, toupper(c));
}
</syntaxhighlight>
</source>
 
== 脚注 ==
465 ⟶ 458行目:
 
== 参考文献 ==
* {{cite book
*日本工業標準調査会『JISX3010 プログラム言語C』2003年12月20日改正
| url = http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
| title = WG14/N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x
| page = 200, 7.4 ''Character handling <ctype.h>''
| publisher = ISO/IEC
| date = 2011-04-12}} -- ISO/IEC 9899:2011(C11)リリース直前のドラフト
* 日本工業標準調査会(当時、現:日本産業標準調査会)『JISX3010 プログラム言語C』2003年12月20日改正(ISO/IEC 9899:1999,Programming languages―C及びISO/IEC 9899 Technical Corrigendum 1:2001の和訳)
 
[[Category:C言語|ひようしゆんらいふらり ]]