3 ms·
The author lists sprintf as one of the ways you can convert a string to a numbers. How would that work?
by criddell 2y ago
The author lists sprintf as one of the ways you can convert a string to a numbers. How would that work?
- randomNumber7 2y agoDid you mean sscanf? You could for example parse a number into a double variable by using "sscanf(str, "%d", &x)" You can even parse a whole line of a csv file with multiple numbers in one call "sscanf(str, "%d;%d;%d\n, &d1, &d2, &d3)"
- criddell 2y agoNo, the article lists sprintf/snprintf. Another person already correctly pointed out that the author was listing a bunch of functions for number and string conversions in general.
- randomNumber7 2y agoprintf makes no sense in this context, because the conversion happens in the other direction. The article doesn't change that. It also lists scanf...
- murderfs 2y agoIt's not a list of ways to convert strings to numbers, it's a list of string conversion functions (i.e. including the other direction). to_string is also listed there.