C和指针之字符操作(<ctype.h>)
生活随笔
收集整理的這篇文章主要介紹了
C和指针之字符操作(<ctype.h>)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、字符操作
在頭文件<ctype.h>中 1、字符分類 islower(int a) 是否是小寫 isupper(int a) 是否是大寫 2、字符轉換 int tolower(int ch)轉換成小寫 int woupper(int ch)轉換成大寫
2、測試Demo
#include <stdio.h>
#include <ctype.h>int main()
{//字符分類char a = 'A';printf("islower(%c) is %d\n", a, islower(a));char b = 'B';printf("isupper(%c) is %d\n", b, isupper(b));char c = 'C';//是不是字母printf("isalpha(%c) is %d\n", c, isalpha(c));//字符轉換char d = 'D';printf("tolower(%c) is %c\n", d, tolower(d));char e = 'e';printf("toupper(%c) is %c\n", e, toupper(c)
總結
以上是生活随笔為你收集整理的C和指针之字符操作(<ctype.h>)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C和指针之字符串strtok函数
- 下一篇: linux之用echo输入数据到文本末尾