So i wrote this in C, so sscanf scans in s but then discards it, then scans in d and stores it. So if the input is "Hello 007", Hello is scanned but discarded and 007 is stored in d.
static void cmd_test(const char *s)
{
int d = maxdepth;
sscanf(s, "%*s%d", &d);
}
So, my question is how can I do the same thing but in C++? possibly using stringstream?
#include <string>
#include <sstream>
static void cmd_test(const char *s)
{
std::istringstream iss(s);
std::string dummy;
int d = maxdepth;
iss >> dummy >> d;
}
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