Y
Hacker News
new
|
ask
|
show
|
jobs
by
abetlen
1930 days ago
Cool trick, thanks for sharing. I don't get why there isn't a suitable snscanf function that takes the buffer length as an argument and returns the number of bytes parsed?
1 comments
froh
1930 days ago
fmemopen takes the buffer length, and there is no need to have the buffer \0 terminated, so instead of strlen you can also just give the buffer size.
The number of bytes parsed can be fetched with the scanf %n format specifier.
link
The number of bytes parsed can be fetched with the scanf %n format specifier.