C 語言標準函數庫分類導覽 - ctype.h islower()

ctype.h 的函數 islower() 測試參數是否為小寫英文字母,滿足條件回傳非 0 的值,否則回傳 0 。



以下程式接受使用者輸入字元,並且判斷是否為小寫英文字母
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    char t;
    
    while (t = getchar()) {
        if (t == EOF) {
            break;
        }
        
        if (t == '\n') {
            continue;
        }
        
        if (islower(t)) {
            printf("對,是小寫字母...\n");
        } 
        else {
            printf("不是小寫字母喔...\n");
        }
    }
    
    return 0;
}

/* 《程式語言教學誌》的範例程式
    http://pydoing.blogspot.com/
    檔名:cislower.c
    功能:示範 ctype.h 中函數 islower() 的使用
    作者:張凱慶
    時間:西元2010年6月 */



編譯後執行,結果如下



您可以繼續參考


沒有留言: