本文介绍了得到例外..,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





#include" stdafx.h"

#include< conio.h>

#include< stdio.h>

#include< string.h>

int main()

{

char * str1 =" United" ;;

char * str2 =" Front";

char * str3;


str3 = strcpy(str1,str2); //在此命令例外情况下


printf("%s",str3);


getch();


返回0;

}

不能在MS VS 6.0和Bloodshed Dev C ++下工作。




#include "stdafx.h"
#include<conio.h>
#include<stdio.h>
#include<string.h>
int main()
{
char *str1 = "United";
char *str2 = "Front";
char *str3;

str3 = strcpy(str1, str2); //AT THIS COMMAND EXCEPTION OCCURS

printf("%s", str3);

getch();

return 0;
}
Not working under MS VS 6.0 and also in Bloodshed Dev C++.

推荐答案



str2指向一个字符串文字,这是不可变的。


你的代码有一个其他问题的数量,但这是你主诉的原因。
-

Andrew Poelstra

要给我发电子邮件,请使用上面的电子邮件地址.com设置为.net

str2 points to a string literal, which is immutable.

Your code has a number of other issues, but this is the cause of
your main complaint.
--
Andrew Poelstra ap*******@wpsoftware.com
To email me, use the above email addresss with .com set to .net



str2指向一个字符串文字,它是不可变的。


str2 points to a string literal, which is immutable.



当然你的意思是str1,因为那是副本的目标。

Of course you meant str1 since that is the target of the copy.



-

删除电子邮件的del

--
Remove del for email



str2指向一个字符串文字,它是不可变的。


str2 points to a string literal, which is immutable.



当然你的意思是str1,因为那是副本的目标。


Of course you meant str1 since that is the target of the copy.



是的,我做过。谢谢。


-

Andrew Poelstra

要给我发电子邮件,请使用.com设置为.net

Yes, I did. Thank you.

--
Andrew Poelstra ap*******@wpsoftware.com
To email me, use the above email addresss with .com set to .net

的上述电子邮件地址

这篇关于得到例外..,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 14:54