C语言tolower和toupper的用法

来源:互联网 发布:网络视听节目 编辑:程序博客网 时间:2024/06/07 20:56
作用:
C库函数 int tolower(int c)转换给定的字母为小写。
C库函数 int toupper(int c)转换给定的字母为大写。

声明

以下是声明的tolower()函数。

int tolower(int c);
以下是声明的toupper()函数
int toupper(int c);

参数

  • c -- 这是字母转换为小写(或者大写)。

头文件:

#include <ctype.h>


例子如下:

#include<stdio.h>

#include <ctype.h>
int main(void)
{
    char ch = 'A';
    ch = tolower(ch);
    printf("ch=%c\n",ch);
    ch = 'b';
    ch = toupper(ch);
    printf("ch=%c\n",ch);
    return 0;
}

输出结果:

ch=a
ch=B

原创粉丝点击