Define a function task01 in task01.cpp that takes a single argument that can be (1) a C…
- User
Define a function task01 in task01.cpp that takes a single argument that can be (1) a C style string, (2) a C++ std::string, or (3) even a raw array of characters. Declare the function with a prototype in task01.h.
The function should take the passed in string data and split it into substrings for each span of either (1) contiguous alphanumeric characters or (2) contiguous punctuation characters. For instance, the string data "This is... maybe... a 1str1ng1." would be broken into the substrings: "This", "is", "...", "maybe", "...", "a", "1string1", ".".
However, the function should not own the data passed in or the substrings returned going out. It should only perform one allocation. It should also work regardless of how large the passed in string is (as long as there is enough RAM). Note that if the function were to create a std::string for each of these substrings, it would potentially allocate for each one of them.
- Assistant