I suppose one should point out that you don't
need to replace anything. "If it ain't broke, don't fix it."
Should I use std::sscanf? |
It's the same function, just wrapped in the std namespace, so you wouldn't be changing any functionality by doing this.
The high-performance, C++ method for this type of parsing would probably be std::from_chars, but it isn't really one-to-one with sscanf, since I don't think it let's you parse 42 out of "ijk 42 xyz".
https://en.cppreference.com/w/cpp/utility/from_chars
But for your purposes, if it's a simple float or int you need to parse, it will still work.
Perhaps simpler would be to use std::stoi or std::stod (string-to-int, string-to-double)
https://en.cppreference.com/w/cpp/string/basic_string/stol
https://en.cppreference.com/w/cpp/string/basic_string/stof
There's multiple ways to do it. Command-line argument parsing is a once-and-done thing, so the method you choose isn't really important.