strupr()函数用于将给定的字符串转换为大写。
句法:
char *strupr(char *str);
范围:
- str:这表示要转换为大写字母的给定字符串。
返回:它返回转换给定的字符串str的字符为大写后得到的修改后的字符串。
下面的程序说明了C语言中的strupr()函数:
范例1:-
// c program to demonstrate
// example of strupr() function.
#include
#include
int main()
{
char str[ ] = "geeksforgeeks is the best";
//converting the given string into uppercase.
printf("%s\n", strupr (str));
return 0;
}
输出:
GEEKSFORGEEKS IS THE BEST
示例2:
// c program to demonstrate
// example of strupr() function.
#include
#include
int main()
{
char str[] = "CompuTer ScienCe PoRTAl fOr geeKS";
printf("Given string is: %s\n", str);
printf("\nstring after converting to the uppercase is: %s", strupr(str));
return 0;
}
输出:
Given string is: CompuTer ScienCe PoRTAl fOr geeKS
string after converting to the uppercase is: COMPUTER SCIENCE PORTAL FOR GEEKS
注意:这是一个非标准函数,仅适用于旧版本的MicrosoftC。
想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。