我陷入了将字符串分配给字符指针的问题。似乎字符指针只占用字符串的前 256 个字符。我在 64 位平台上工作。同样的代码也适用于 32 位平台。我不明白为什么在 64 位平台的 char 指针变量中只分配了 256 个字符,任何人都可以帮忙.. 在此先感谢。
我的测试是
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)。