-
isspace
鎖定
isspace,計算機函數,主要用於檢查參數c是否為空白字符。
- 外文名
- isspace
- 表頭文件
- #include<ctype.h>
- 定義函數
- int isspace(int c)
isspace簡介
函數説明
檢查參數c是否為空白字符,也就是判斷是否為空格(' ')、水平定位字符
返回值
若參數c為空格字符,則返回非0,否則返回0。
isspace範例
將字符串str中內含的空格字符找出,並顯示空格字符的ASCII碼
#include<ctype.h> #include<stdio.h> int main(void) { int i; char str[] = "123c @# FD\tsP[e?\n"; for(i=0; str[i]!=0; i++) { if( isspace(str[i]) ) printf("str[%d] is a white-space character:%d\n", i, str[i]); } return 0; }
執行
str[4] is a white-space character:32
str[7] is a white-space character:32
str[10] is a white-space character:9 /* \t */
str[16] is a white-space character:10 /* \n */
- 參考資料
-
- 1. ASCII碼對照表 .911cha[引用日期2012-08-07]
- 詞條統計
-
- 瀏覽次數:次
- 編輯次數:16次歷史版本
- 最近更新: G敏吖吖