问题
I don't know much python but from what I can tell from the documentation the code:
str = "AAAA"
str += pack("<I", 0)
would append the result of the pack function to str, which would be the integer value of 0 in little-endian style. My question is what the C equivalent of this would be. Would it just be:
char str[20] = "AAAA";
strcat(str, "\x00");
?...
回答1:
strcat() stops at the first NUL, so no.
char str[20] = "AAAA";
int val = 0;
int nval = htole32(val);
memcpy(str + 4, (char*)&nval, 4);
来源:https://stackoverflow.com/questions/10771070/what-is-the-c-equivalent-of-pythons-packi-0