no, you need to do `userString[count] == '!' || userString[count] == '.' || userString[count] == '?'`
– Ryan HainingNov 17 '20 at 00:52
That is what I thought at first but was shying away from it because my coding class frowns upon using repetitive code, in this case userString[count] three times. I wonder if theres a library function that returns true for punctuation. thank you!
– BellfrankNov 17 '20 at 00:53
1
There's `ispunct()` from ``, but that returns true for more punctuation characters than the three you show (such as `,` and `(` and `>`, etc). Otherwise, you could look at a search algorithm that takes a string with the acceptable characters and looks up the current character in the string — in C, you could use `strchr(".!?", userString[count])` (from `` — presumably `` in C++), or something similar.
– Jonathan LefflerNov 17 '20 at 01:06
Well, one can always fallback to C and try `if (strchr("!,?", userString[count]) != 0)`. Nothing wrong with using C. But only if it's used correctly, of course.
– Sam VarshavchikNov 17 '20 at 01:29
or `if (std::string{"!.?"}.find(userString[count]) != std::string::npos)` or c++17 forwards: `if (std::string_view{"!.?"}.find(userString[count]) != std::string_view::npos)`
– Ryan HainingNov 17 '20 at 20:23