C++ 本地化庫 - isspace



描述

它檢查字元是否為空格,其他語言環境可能會將不同的字元選擇視為空格,但絕不會是對於 isalnum 返回 true 的字元。

宣告

以下是 std::isspace 的宣告。

C++98

int isspace ( int c );

C++11

int isspace ( int c );

引數

c − 要檢查的字元,轉換為 int 型別,或 EOF。

返回值

它返回一個非零值。

異常

無異常保證 − 此函式從不丟擲異常。

示例

以下為 std::isspace 的示例。

#include <stdio.h>
#include <ctype.h>
int main () {
   char c;
   int i=0;
   char str[]="tutorials point india pvt ltd\n";
   while (str[i]) {
      c=str[i];
      if (isspace(c)) c='\n';
      putchar (c);
      i++;
   }
   return 0;
}

示例輸出應如下所示:

tutorials
point
india
pvt
ltd
locale.htm
廣告