将字符串分配给64位错误的char指针

时间:2013-05-16 07:35:32

标签: c++ string pointers 64-bit 32bit-64bit

我遇到了将字符串分配给字符指针的问题。似乎字符指针只占用了字符串的前256个字符。我在64位平台上工作。同样的代码也适用于32位平台。我无法弄清楚为什么只有256字符只被分配在64位平台的char指针变量中,任何人都可以请帮助..提前感谢。

我的测试

const char *test2=
    "Hello everyone"
    "Please help me"
    "my string assigning part to char pointer in a code is not working"
    "I have been stucked on it for 3 days."
    "I tried lot of things"
    "but the problem persists."
    "I have no idea why the code is not working"
    " Here comes The problem in next line..."
    "If you get this line in the up assigning variable..yuppieee";

const char *test3="Hello everyone .Please help me my string assigning part to char pointer in a code is not working I have been stucked on it for 3 days. I tried lot of things but the problem persists. I have no idea why the code is not working  Here comes The problem in next line... If you get this line in the up assigning variable..yuppieee";

结果

test2 ="Hello everyonePlease help memy string assigning part to char pointer in a code is not workingI have been stucked on it for 3 days.I tried lot of thingsbut the problem persists.I have no idea why the code is not working Here comes The problem in next line.."

test3 ="Hello everyone .Please help me my string assigning part to char pointer in a code is not working I have been stucked on it for 3 days. I tried lot of things but the problem persists. I have no idea why the code is not working  Here comes The problem in nex"

只有前256个字符被赋予变量。

代码

 #include <iostream>
 #include <string>
#include <conio.h>
using namespace std;
int main()
{

const char *test3="Hello everyone .Please help me my string assigning part to char pointer in a code is not working I have been stucked on it for 3 days. I tried lot of things but the problem persists. I have no idea why the code is not working  Here comes The problem in next line... If you get this line in the up assigning variable..yuppieee";

cout<<test3<<endl<<endl;
getch();
return 0;

}

项目设置为在64位编译模式下的vs2005中的项目属性中包含公共语言支持运行时(/ clr)。

0 个答案:

没有答案