AnsweredAssumed Answered

How to sprintf an uint32_t value

Question asked by prieur.jean on Jul 16, 2015
Hello everybody,

Amateur question: I search for a long time how to sprintf a 32bit value in a string.

If I use 
sprintf(string_to_write, "%u", uint32_value);
The value is cropped as a 16 bit value.
The compiler displays "warning: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'uint32_t'"

If I use 
sprintf(string_to_write, "%lu", uint32_value);
The compiler displays no warning but nothing is printed in my string_to_write

Do you have any ideas? This is the function of my printf.c librairy:
signed int sprintf(char *pStr, const char *pFormat, ...)
{
    va_list ap;
    signed int result;
 
    // Forward call to vsprintf
    va_start(ap, pFormat);
    result = vsprintf(pStr, pFormat, ap);
    va_end(ap);
 
    return result;
}

Thanks a lot!

Outcomes