I want to pass an int to a function that expects a char *. Programming in Linux, so can't use itoa.
The function header looks like this:
void swapEndian(char *pElement, unsigned int uNumBytes)
and calling the function with an int (I know, this won't work..)
So what must I do to
to pass it to this function?
Last edited on
Try the following
swapEndian( reinterpret_cast<char *>( &numLine ), sizeof(int));
reinterpret_cast is C++. Maybe this was not the correct forum to ask the question as I'm programming C, but if anyone can give me a C solution, will be appreciated.
If your function requires a character string, then you could use sprintf() to make the int into a string.