-1

So, Hello Guys.

I have a function, which reads the Diskdrive Serialnumber. I get a output like this:

SerialNumber A6PZD6FA 1938B00A49382 0000000000000 (thats not my serialnumber, just the format)

So now, i want to split the 3 numbers, or strings, however i call it you know what i mean, and save it in in three independent strings.

string a = {A6PZD6FA this value} string b = {1938B00A49382 this value} string c = {0000000000000 this value}

After that, i want to create a oneline "synonym" for all 3 strings. So i mean, string synonym = 04930498SV893948AJVVVV34 something like this.

Flawless
  • 3
  • 1
  • Use a `std::istringstream` for extraction, and i have no clue what you're talking about in your last statement, so *"however i call it you know what i mean"* is an overtly presumptive assumption. – WhozCraig Oct 15 '20 at 18:51

1 Answers1

0

If you have the original text in a string variable, you can use a std::istringstream to parse it into constituent parts:

std::string s = "SerialNumber A6PZ etc etc...";
std::istringstream iss{s};
std::string ignore, a, b, c;
if (iss >> ignore >> a >> b >> c) {
    std::string synonym = a + b + c;
    ...do whatever with synonym...
} else
    std::cerr << "your string didn't contain four whitespace separated substrings\n";
Tony Delroy
  • 94,554
  • 11
  • 158
  • 229