R.Wieser
2022-06-16 14:54:28 UTC
Hello all,
I'm trying to use fscanf to read a certain string, using this formatting :
" someid=%u%[;]c"
The latter part, "%[;]c" is a trick to detect if the whole string is read :
Only if the ";" is encountered the result of fscanf equals 2 (can't use
"%n", as that doesn't up the result count).
The thing is that I actually took a look at what got stored, and found that
instead of a single byte, 0x3B, *two* where stored, 0x003B. When I remove
the "[;]" it goes back to storing a just single byte.
Can somebody explain to my why the extra 0x00 happens (what the reason for
it is) ?
Second question : Is there some way I can tell fscanf that it should match
upto the terminating zero (so I can do away with the "%[;]c" cludge
altogether) ?
Regards,
Rudy Wieser
I'm trying to use fscanf to read a certain string, using this formatting :
" someid=%u%[;]c"
The latter part, "%[;]c" is a trick to detect if the whole string is read :
Only if the ";" is encountered the result of fscanf equals 2 (can't use
"%n", as that doesn't up the result count).
The thing is that I actually took a look at what got stored, and found that
instead of a single byte, 0x3B, *two* where stored, 0x003B. When I remove
the "[;]" it goes back to storing a just single byte.
Can somebody explain to my why the extra 0x00 happens (what the reason for
it is) ?
Second question : Is there some way I can tell fscanf that it should match
upto the terminating zero (so I can do away with the "%[;]c" cludge
altogether) ?
Regards,
Rudy Wieser