char *sBuffer=new char[20];
char * sStringStart = sBuffer;
long * plMsgStart = (long *) sBuffer;// what is this line doing
long i=500;
*plMsgStart = i // what is this line doing
最后一行是在 char 数组中分配 500 吗?但是当我打印数组时,我得到垃圾值
大家好,下面是实际代码,我在将代码从 c++ 转换为 c# 时遇到它,下面的代码是 c++ 函数的一部分,现在为什么下面的函数给出垃圾值?
char *sBuffer=new char[20];
char * sStringStart = sBuffer;
BSTR bsMsgBody= SysAllocString(L"Helo");
sStringStart+=4;
long * plMsgStart = (long *) sBuffer;
long l=50;
*plMsgStart=l;
sprintf(sStringStart, "%S", bsMsgBody);
printf("%S",sBuffer);