sscanf string corruption
October 20, 2009 09:24PM
I've been using sscanf to get content from strings and never had any problem...until now.
The problem only appears to be there when I try to read u8 from the string. Instead of storing the value in the destination value, sscanf stores it back in the begining of the string. For example:
I have the string buffer = "17 1"
and call sscanf(buffer, "%hhu %hhu", &type, &version);
then all I get is version = 0(alwais zero, no matter the old value), type = 0(alwais zero, no matter the old value), and buffer = "#7 1" (but instead of # I have the 17th symbol of ascii table, couldn't post it in the forum)

So sscanf, reads the 17 properly but stores it wrong (in buffer's adress instead of type's adress) and then stores nothing more (thought I think it reads both two values, since it returns 2"

I can't figure out any reasonable explanation for this, might this be a bug in sscanf?
someone got to read unsigned chars from a text file?
Re: sscanf string corruption
October 24, 2009 04:00PM
I ran a similar test and I also see incorrect results. This looks like a bug to me.
Sorry, only registered users may post in this forum.

Click here to login