初学者求教:同样的一段简单代码在Win-TC中运行成功,在VC6中运行出错
//某C语言教材中的例子,代码如下:
程序代码:main()
{
void string_copy();
char *s1, *s2;
s1 = "Good morning";
s2 = "How do you do";
printf("%s\n%s\n", s1, s2);
string_copy(s2, s1);
printf("%s\n%s\n", s1, s2);
}
void string_copy(s, t)
char *s, *t;
{
while ((*s = *t) != '\0')
{
s++;
t++;
}
}在Win-TC中编译运行成功,输出:
Good morning
How do you do
Good morning
Good morning
可是在VC6中编译通过无错,也无警告,但运行时:
显示
Good morning
How do you do
之后紧接着弹出错误窗口,说是 .exe 出现问题。
之后本应输出的
Good morning
Good morning
未能显示成功。
====================
作为初学者,对于这种问题想不出答案。
请指点。感谢。
[ 本帖最后由 sakyamuni 于 2010-10-12 21:31 编辑 ]









