| 查看: 305 | 回复: 1 | |||
zhaowengen木虫 (小有名气)
|
[求助]
为什么这个程序会发生运行时错误?
|
|
#include <stdio.h> #define NULL 0 #define FALSE 0 #define TRUE 1 char * match(char * str, char * want) { while(*want != '\0') { if(*str++ != *want++) return NULL; } return str; } int del_substr(char * str, char const * substr) { char * next = NULL; while(*str != '\0') { next = match(str, (char *)substr); if(next != NULL) break; str++; } if(*str == '\0') return FALSE; while(*str++ = *next++) ; return TRUE; } int main(void) { char * str = "ABCDEFG"; char * substr = "CD"; int val = 0; val = del_substr(str, substr); printf("%s\n", str); return 0; } |
» 猜你喜欢
现代”学阀”该如何界定
已经有12人回复
国社科系统bug了,是不是要放榜了?
已经有10人回复
课题组招2027级博士 上海工程技术大学 激光智能制造方向
已经有4人回复
上海工程技术大学 激光智能制造课题组 2027级博士研究生招生
已经有3人回复
上海工程技术大学激光智能制造课题组|2027级博士研究生招生公告
已经有11人回复
我的奶奶
已经有3人回复
zhaowengen
木虫 (小有名气)
- 应助: 1 (幼儿园)
- 金币: 4389.7
- 帖子: 102
- 在线: 134.9小时
- 虫号: 3760377
- 注册: 2015-03-24
- 性别: GG
- 专业: 计算机网络
2楼2015-08-21 10:58:04










回复此楼