代码如下:
void Test1(const char * pBuf, int Len)
{
char * p = new char[4];
*(short *)(pBuf+2) = 99;//??
pBuf[2] = 'c';//err
pBuf = p;
return ;
}
void Test2(char * const pBuf, int Len)
{
char * p = new char[4];
*(short *)(pBuf+2) = 44;//??
pBuf[2] = 'b';
pBuf = p;//err
return ;
}
为什么 *(short *)(pBuf+2) = 44; 这种写法却可以改变 传入参数的内容 |