Why wouldn't it just work?
const char* ip = "192.168.1.4";
unsigned int ip4[4];
sscanf(ip,"%o.%o.%o.%o",ip4,ip4+1,ip4+2,ip4+3); // doesn't work
sscanf(ip,"%d.%d.%d.%d",ip4,ip4+1,ip4+2,ip4+3); // works
I checked man pages for scanf(3) and it clearly states that %o is perfectly acceptable.
There is no "8" and "9" in octal, so 192 and 168 aren't octal numbers, so sscanf can't parse them as octal numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With