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)
精彩评论