islower() - C函式


C庫函式 int islower(int c)檢查傳遞的字元是否是小寫字母。

宣告

以下是islower()函式的宣告。

int islower(int c);

引數

  • c -- 這是要檢查的字元。

返回值

這個函式如果c是一個小寫字母返回一個非零值(true),否則0(false)

範例

下面的例子顯示islower()函式的用法。

#include <stdio.h>
#include <ctype.h>

int main()
{
   int var1 = 'Q';
   int var2 = 'q';
   int var3 = '3';
    
   if( islower(var1) )
   {
       printf("var1 = |%c| is lowercase character
", var1 );
   }
   else
   {
      printf("var1 = |%c| is not lowercase character
", var1 );
   }
   if( islower(var2) )
   {
       printf("var2 = |%c| is lowercase character
", var2 );
   }
   else
   {
      printf("var2 = |%c| is not lowercase character
", var2 );
   }
   if( islower(var3) )
   {
       printf("var3 = |%c| is lowercase character
", var3 );
   }
   else
   {
      printf("var3 = |%c| is not lowercase character
", var3 );
   }
   
   return(0);
}

讓我們編譯和執行上面的程式,這將產生以下結果:

var1 = |Q| is not lowercase character
var2 = |q| is lowercase character
var3 = |3| is not lowercase character