发布网友
共5个回答
热心网友
原型:
extern char *strupr(char *s);头文件:
#include <string.h>功能:将字符串s转换为大写形式
说明:只转换s中出现的小写字母,不改变其它字符。返回指向s的指针。
兼容性说明:strupr不是标准C库函数,只能在VC中使用。在linux gcc环境下需要自行定义这个函数。
举例:
// strupr.c相关函数:strlwr
热心网友
注意:"beijing"是一个字符串常量。
让我们看看strupr的原型和介绍:
char*_strupr(char*string);
Return Value
These functions return a pointer to the altered string. Because the
modification is done in place, the pointer returned is the same as the pointer
passed as the input argument. No return value is reserved to indicate an
error.
----------------------------------------------------------------
返回的char*指针,是和传入的参数指针string指向同一地址的,char s[]="beijing";,这样是用变量s来记录常量地址,因此可以通过。
但是直接传入常量"beijing",要注意常量是不能被修改的,因此会报错。
热心网友
去掉"memory.h"
char ss="love china";
===>
char ss[]="love china";
因为 char是字符型,只能存储一个字符,而你要“强行”赋给它一个字符串,那它就“爆”了
char []是字符数组,可以存储N个字符,所以可以
热心网友
#include <stdio.h>
#include <memory.h>
#include <string.h>
main()
{
char ss="love china";//这一行就有错误了,应该是 char ss[]="love china";
char *ad;
ad=strupr(ss);
printf("string ss:%s\n",ad);
}
热心网友
#include <stdio.h>
#include <memory.h>
#include <string.h>
void main()
{
char ss[]="love china";
char *ad;
ad=strupr(ss);
printf("string ss:%s\n",ad);
}