C 中的 ispunct()


函式 ispunct() 用於檢查所傳遞的字元是否為標點符號。如果不是標點符號,則返回零;否則返回一個非零值。

以下是在 C 語言中 ispunct() 的語法:

int ispunct(int character);

以下是在 C 語言中 ispunct() 的一個示例:

示例

 即時演示

#include <stdio.h>
#include<ctype.h>
int main() {
   int a = '!';
   int b = 'a';
   if(ispunct(a))
   printf("The character is a punctuation.");
   else
   printf("
The character is not a punctuation.");    if(ispunct(b))    printf("
The character is a punctuation.");    else    printf("
The character is not a punctuation.");    return 0; }

輸出

The character is a punctuation.
The character is not a punctuation.

更新時間: 24-6-2020

96 次瀏覽

開啟你的 職業 生涯

透過完成課程來獲取認證

開始
廣告
© . All rights reserved.