对char *的怀疑 [英] doubt on char *

查看:83
本文介绍了对char *的怀疑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int myfun(char * sourcebuf)

{

char * destbuf;

char ch;

while(* sourcebuf!=''\''')

{

* destbuf ++ = * sourcebuf ++; - 撞到这里

};

返回1;

}


任何人都可以解释为什么它会崩溃?

谢谢......

int myfun(char *sourcebuf)
{
char *destbuf;
char ch;
while (*sourcebuf != ''\0'')
{
*destbuf++=*sourcebuf++; --crashed here
};
return 1;
}

Can any one explain why it is crashed?
Thankyou...

推荐答案

Fastro写道:
Fastro wrote:

int myfun(char * sourcebuf)

{

char * destbuf;

char ch;

while(* sourcebuf!=''\''')

{

* destbuf ++ = * sourcebuf ++; - 撞到这里

};

返回1;

}


任何人都可以解释为什么会崩溃?

谢谢...
int myfun(char *sourcebuf)
{
char *destbuf;
char ch;
while (*sourcebuf != ''\0'')
{
*destbuf++=*sourcebuf++; --crashed here
};
return 1;
}

Can any one explain why it is crashed?
Thankyou...



看起来可能不像,但这是问题7.1中的

comp.lang.c常见问题解答(FAQ)列表

< http://www.c-faq.com/>。

-
Er ********* @ sun.com


文章< 92 **************************** ****** @ y22g2000prd。 googlegroups.com>,

Fastro< le ******* @ gmail.comwrote:
In article <92**********************************@y22g2000prd. googlegroups.com>,
Fastro <le*******@gmail.comwrote:

> int myfun( char * sourcebuf)
{
char * destbuf;
char ch;
while(* sourcebuf!=''\ 0'')
{
* destbuf ++ = * sourcebuf ++; - 撞到这里
};
返回1;
}

任何人都可以解释它崩溃的原因吗?
谢谢...
>int myfun(char *sourcebuf)
{
char *destbuf;
char ch;
while (*sourcebuf != ''\0'')
{
*destbuf++=*sourcebuf++; --crashed here
};
return 1;
}

Can any one explain why it is crashed?
Thankyou...



这可能是你的编辑软件中的一个错误。


当你写道:


int myfun(char * sourcebuf,char * destbuf)


它出现为:


int myfun(char * sourcebuf)

{

char * destbuf;


不幸的是,编译器本身无法解决这个问题。

It may be a bug in your editing software.

When you wrote:

int myfun(char *sourcebuf, char *destbuf)

It came out as:

int myfun(char *sourcebuf)
{
char *destbuf;

And, unfortunately, the compiler couldn''t fix this by itself.


Fastro写道:**代码稍微编辑**
Fastro wrote: ** code edited slightly **

>

int myfun(char * sourcebuf){

char * destbuf;

char ch;

while(* sourcebuf!=''\ 0''){

* destbuf ++ = * sourcebuf ++; - 撞到这里

};

返回1;

}


任何人都可以解释为什么它会崩溃?
>
int myfun(char *sourcebuf) {
char *destbuf;
char ch;
while (*sourcebuf != ''\0'') {
*destbuf++=*sourcebuf++; --crashed here
};
return 1;
}

Can any one explain why it is crashed?



是的。 destbuf未初始化。它没有指向任何存储空间。


-

[邮件]:Chuck F(cinefalconer at maineline dot net)

[page]:< http://cbfalconer.home.att.net>

尝试下载部分。


**发布自 http://www.teranews.com **

Yes. destbuf is uninitialized. It doesn''t point to any storage.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

** Posted from http://www.teranews.com **


这篇关于对char *的怀疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆