我不太了解python,但从文档中我可以看出代码:
str = "AAAA" str += pack("<I", 0)
会将pack函数的结果附加到str,这将是little-endian风格的整数值0。我的问题是 C 等价物是什么。会不会是:
char str[20] = "_Stack Overflow中文网
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
char str[20] = " 问问题
char str[20] = "AAAA"; strcat(str, "\x00");
?...
strcat()停在第一个 NUL,所以没有。
strcat()
char str[20] = "AAAA"; int val = 0; int nval = htole32(val); memcpy(str + 4, (char*)&nval, 4);