Been coding C++ for about a week now haha, and have run in to a problem. I am working through a book and one of the exercises calls for reading a string that has punctuation marks in it and then printing the string, but without those punctuation marks.
Now, on using the string "Hello World!!!" (yes, indeed) and the following code I can succeed in printing "Hello World" which is great:
1 2 3 4 5 6 7 8 9 10 11 12
using std::string; using std::cout; using std::cin; using std::endl;
int main ()
string s ("Hello World!!!");
for (decltype(s.size()) index = 0;
index != s.size() && !ispunct(s[index]); ++index)
cout << s[index];
However, I got to thinking, what happens if one has a string that looks like "Hello, World!!!", or "Thi.s str&in$g is mess$ed up" how would I adapt the above code in order to return "Hello World" or "This string is messed up"?