I implemented myPrintf function:
int myPrintf(const char* format,...)
{
va_list args;
va_start(args, format);
int ret = vprintf (format, args);
fflush(stdout);
va_end (args);
return ret;
}
When I run the function with format = “%ld,%ld”
and the args representation as set of chars is 78,97,188,0,0,0,0,0,120,10,227,5,0,0,0,0
the output printed to stdout is 12345678,0.Instead of 12345678,98765432.
What could be the problem?And how could it be solved?
Because, like on ideone, your
longs are 32 bitshttp://ideone.com/jjafU
If you use
"%lld"for 64-bit values, it works as you expecthttp://ideone.com/BYTaa