C语言isupper()函数:判断字符是否为大写字母

isupper()函数

头文件和函数原型

#include <ctype.h>
int isupper(int c);

描述

isupper()是C语言标准库中的一个函数,用于判断一个字符是否为大写字母(A~Z,ASCII码为65~90);

返回值

传入的字符参数是一个大写字母时,返回非0值,否则返回0

示例代码

这个示例将指出字符串中大写字母的位置;

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

int main() {

	char arr[] = "Success is the Result of Hard Work, " \
		"Persistence, and Determination.";

	printf("%s\n", arr);
	
	size_t length = strlen(arr);
	for (int i = 0; i < length; i++) {
		printf("%c", isupper(arr[i]) ? '^' : ' ');
	}

	printf("\n");
	
}

程序运行结果

Success is the Result of Hard Work, Persistence, and Determination.
^              ^         ^    ^     ^                ^

原创内容,如需转载,请注明出处;

本文地址: https://www.perfcode.com/c-functions/isupper.html

分类: 计算机技术
推荐阅读:
Python数组求和 给定一个数组,使用Python进行数组求和;
Python函数修饰符@的详细教程 Python函数修饰符@的作用是为现有的函数增加额外的功能;其作用非常强大,今天我们就来谈谈它是如何在日志记录中起到很好的作用的。
System has not been booted with systemd as init system (PID 1). Can't operate.解决方法 在WSL(Windows Subsystem for Linux,适用于Linux的Windows子系统)下通过systemctl命令启动某些服务将造成System has not been booted with systemd as init system (PID 1). Can't operate.这样的错误;
Windows安装Golang最新版本 首先,你需要下载Golang的最新安装包,你可以到官网去,Golang的官方网站为:golang.org,但这个网站国内用户无法访问,好在Google提供了第二个Golang下载页面:
Kali更换国内源 默认情况下,kali系统使用的是官方提供的源,有的时候速度不错,有的时候速度不敢恭维,所以最好是将Kali源更改为国内的,这样安装软件和更新程序都可以享受到非常快的速度;
Python eval()函数 在Python中,eval()是一个内置函数,用于将一个字符串作为Python表达式执行,并返回表达式的结果。