C 庫函數 - tolower()

C 標準庫 - <ctype.h> C 標準庫 - <ctype.h>

描述

C 庫函數 int tolower(int c) 把給定的字母轉換為小寫字母。

聲明

下麵是 tolower() 函數的聲明。

int tolower(int c);

參數

  • c -- 這是要被轉換為小寫的字母。

返回值

如果 c 有相對應的小寫字母,則該函數返回 c 的小寫字母,否則 c 保持不變。返回值是一個可被隱式轉換為 char 類型的 int 值。

實例

下麵的實例演示了 tolower() 函數的用法。

實例

#include <stdio.h> #include <ctype.h> int main() { int i = 0; char c; char str[] = "zaixian"; while( str[i] ) { putchar(tolower(str[i])); i++; } return(0); }

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

zaixian

C 標準庫 - <ctype.h> C 標準庫 - <ctype.h>