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.

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:

#include  int 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!