Question
checkLastLine Using C++, create a function named checkLastLine that receives a multi-line string and checks if the last non-blank line of the string begins with
checkLastLine
Using C++, create a function named checkLastLine that receives a multi-line string and checks if the last non-blank line of the string begins with a particular string (also knowns as a pattern). The function returns true if the multi-line string starts with the pattern; otherwise false. PUT THE FULL WORKING CODE IN ONE FILE. MAKE SURE THERE ARE NO ERRORS.
The function should be named checkLastLine (Case sensitive). It should return a bool value and accept two strings by reference. The first string is the multiline string, and the second is the pattern.
Submit your source code for the function in a file named functions_checkLastLine.cpp
Example test code:
#includeint main() { // Creates a multi-line string string multiLine = R"(T: a A: T: p A: d A: o T: p T: T: l A: g T: e T: )"; string conduit{}, pattern{}; // Checks if the last non-blank line does not begin with "R:" bool result = checkLastLine(multiLine, "R:"); // The value should be false assert(!result); // Checks if the last non-blank line begins with "T:" result = checkLastLine(multiLine, "T:"); // The value should be true assert(result); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started