I'm trying to get rid of old unsafe C functions, including sscanf(). Right now I'm using
#include <sstream>
std::string str = "111 222.2 333 444.4 555";
std::stringstream sstr(str);
int i, j, k;
float dummy1, dummy2;
sstr >> i >> dummy1 >> j >> dummy2 >> k;
I just need the integers from that. Is there any way to avoid those nasty dummy variables?
Thanks in advance and have a nice day!
sstr.ignore(128,' ');
Ignore until next space, or until 128 characters were read.
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