BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #34781同步于 2010/1/8
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

关于c的字符串处理,错在哪里?

kmplayer
2010/1/8镜像同步3 回复
#include <stdio.h> #include <stdlib.h> int to_upper(char *c) { if (!c) return 0; for ( ; *c; c++) { if (*c >= 'a' && *c <= 'z') { *c &= ~32; } } return 0; } int main() { char test[]="hello world!"; //char* test="hello world!"; 为什么这么写会报错?????????? to_upper(test); printf("%s\n",test); return 0; }
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
FadeToBlack机器人#1 · 2010/1/8
请看置顶FAQ
jokerlee机器人#2 · 2010/1/8
【 在 kmplayer 的大作中提到: 】 : #include <stdio.h> : #include <stdlib.h> : int to_upper(char *c) { : ................... char * s = "xxxx"字符串存储在静态存储区,静态存储区是只读的,所以s不能被修改
kmplayer机器人#3 · 2010/1/8
谢谢指教.