得到例外..,
#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++.
2008-08-12,Pranav< pr ******* @ gmail.comwrote:
On 2008-08-12, Pranav <pr*******@gmail.comwrote:
>
char * str1 =" United" ;;
char * str2 =" Front";
char * str3;
str3 = strcpy(str1,str2); //在这个命令异常发生时
>
char *str1 = "United";
char *str2 = "Front";
char *str3;
str3 = strcpy(str1, str2); //AT THIS COMMAND EXCEPTION OCCURS
str2指向一个字符串文字,这是不可变的。
你的代码有一个其他问题的数量,但这是你主诉的原因。
-
Andrew Poelstra ap ******* @ wpsoftware.com
要给我发电子邮件,请使用上面的电子邮件地址.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
2008年8月12日星期二04:34:22 GMT,Andrew Poelstra< no **** @ nospam.com>
写道:
On Tue, 12 Aug 2008 04:34:22 GMT, Andrew Poelstra <no****@nospam.com>
wrote:
> 2008-08-12,Pranav< pr ******* @ gmail.comwrote:
>On 2008-08-12, Pranav <pr*******@gmail.comwrote:
>>
char * str1 =" United" ;;
char * str2 =" Front";
char * str3 ;
str3 = strcpy(str1,str2); //在此命令异常发生时
>>
char *str1 = "United";
char *str2 = "Front";
char *str3;
str3 = strcpy(str1, str2); //AT THIS COMMAND EXCEPTION OCCURS
str2指向一个字符串文字,它是不可变的。
str2 points to a string literal, which is immutable.
当然你的意思是str1,因为那是副本的目标。
Of course you meant str1 since that is the target of the copy.
>
>
Your code has a number of other issues, but this is the cause of
your main complaint.
-
删除电子邮件的del
--
Remove del for email
2008-08- 12,Barry Schwarz< sc ****** @ dqel.comwrote:
On 2008-08-12, Barry Schwarz <sc******@dqel.comwrote:
On Tue,2008年8月12日04:34:22 GMT,Andrew Poelstra< ;没有**** @ nospam.com>
写道:
On Tue, 12 Aug 2008 04:34:22 GMT, Andrew Poelstra <no****@nospam.com>
wrote:
>> 2008-08-12,Pranav< ; pr ******* @ gmail.comwrote:
>>On 2008-08-12, Pranav <pr*******@gmail.comwrote:
>>>
char * str1 =" United" ;;
char * str2 =" Front";
char * str3;
str3 = strcpy(str1,str2); //在此命令异常发生时
>>>
char *str1 = "United";
char *str2 = "Front";
char *str3;
str3 = strcpy(str1, str2); //AT THIS COMMAND EXCEPTION OCCURS
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 ap * ****** @ wpsoftware.com
要给我发电子邮件,请使用.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
的上述电子邮件地址