I need a function that ignore reading the rest of a string
For example if a character is "/" I want to ignore reading it and what comes after it till the end of the string .
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string a = " adfh//ghjl";
size_t pos = a.find('/'); // look for specific character
if (pos != string::npos) // if it is found
{
a = a.substr(0, pos); // select substring starting at character - and of length pos
}
cout << "a = (" << a << ")\n";
string b = " adfh?ghjl";
pos = b.find_first_of(".,\\;!?/#"); // look for any of these characters
if (pos != string::npos) // if any are found
{
b.resize(pos); // change size of string - discarding rest.
}
cout << "b = (" << b << ")\n";
}