Sprintf printing wrong value for unsigned int in c++
I have the following variables and sprintf function...

    unsigned int user_id = 1;
    unsigned int order_id = 2;
    unsigned int volume = 1;

    char buffer[128];
    sprintf(buffer,"u_id=%u|o_id=%u|v=%u",user_id, order_id, volume);

When I look at buffer all values are properly written except the last one, no matter if I switch volume to another variable. If I switch volume to a different position, it gets properly written into the string, but w/e variable is last gets written incorrectly. 

Incorrectly means the wrong value, what I assume to be the signed version of the variable, as in instead of 1 it will print out 4701175. Is there a reason for this, and can it be fixed?



Sprintf printing wrong value for unsigned int in c++
===

I have the following variables and sprintf function...

    unsigned int user_id = 1;
    unsigned int order_id = 2;
    unsigned int volume = 1;

    char buffer[128];
    sprintf(buffer,"u_id=%u|o_id=%u|v=%u",user_id, order_id, volume);

When I look at buffer all values are properly written except the last one, no matter if I switch volume to another variable. If I switch volume to a different position, it gets properly written into the string, but w/e variable is last gets written incorrectly. 

Incorrectly means the wrong value, what I assume to be the signed version of the variable, as in instead of 1 it will print out 4701175. Is there a reason for this, and can it be fixed?


