😸

[C] isgraph 関数

に公開

機能

isgraph は、引数が「空白以外の表示可能な文字」なら真(0以外)を返す標準ライブラリ関数です。[1]

使用例

a, 1, ! と表示する

\n は改行を表す エスケープシーケンス[2]

コード

printf("%d,%d,%d", isgraph('a'), isgraph('1'), isgraph('!'));
全文
#include <stdio.h>
#include <ctype.h>
void main() {
    printf("%d,%d,%d", isgraph('a'), isgraph('1'), isgraph('!'));
}

実行結果

1,1,1

文字を変数から判定して表示する

コード

char c = ' ';
printf("%d", isgraph(c));
全文
#include <stdio.h>
#include <ctype.h>
void main() {
    char c = ' ';
    printf("%d", isgraph(c));
}

実行結果

0
脚注
  1. 判定対象は半角英数字・記号など。スペースや制御文字は偽と判定します。 ↩︎

  2. 改行やタブなど、画面に表示されない制御文字のこと。 ↩︎

Discussion