开发者

C: Turning ints into char* buffers?

I'm working on a strange little embedded platform that seems to have开发者_开发百科 undefined behavior when calling their POSIX-compliance functions with source pointers that are anything other than a char*. It's kind of a stupid workaround, but how would I go about converting an int in C to a character buffer with the same bit ordering?

For example:

int foo = 15;
turning into
char* bar = "\x00\x0F\x00\x00";


Use this method:

function((char *)&bar)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜