複製鏈接
請複製以下鏈接發送給好友

isspace

鎖定
isspace,計算機函數,主要用於檢查參數c是否為空白字符。
外文名
isspace
表頭文件
#include<ctype.h>
定義函數
int isspace(int c)

目錄

isspace簡介

函數説明
檢查參數c是否為空白字符,也就是判斷是否為空格(' ')、水平定位字符
('\t')、歸位鍵('\r')、換行('\n')、垂直定位字符('\v')或翻頁('\f')的情況。 [1] 
返回值
若參數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 */
參考資料