Pages

Sunday, 29 August 2021

Chapter 20 // Exercise 10 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2019 and a modified version of the std_lib_facilities header found here.

Chapter 20 // Exercise 10

Define a version of the word-counting program where the user can specify the set of whitespace characters.


I guess for this one he meant that the user can supply several characters at once so "a, 1, -, 9" are "whitespace" characters. For this I created a simple function called isCustomWhitespace(char c, string s). This used std::strings find() function to find c in s. I could then just use this like I did in the previous exercise with isspace() and isalpha().

No comments:

Post a Comment