问题
code like this:
int totalLen = 50;
int usTest = htons(totalLen);
char* strBuf = new char[totalLen ];
memcpy(strBuf,&usTest,sizeof(int));
after this,there is nothing in strBuf, why?
but if I put a big number, like 100000001
, it will be OK?
what's the problem?
来源:https://stackoverflow.com/questions/19818704/use-htonl-convert-a-int-number-and-memcpy-to-a-char-but-nothing