#include #include #include // Two strings are equal if they both have the same // number of characters and each pair of corresponding // characters is the same. // // Author a function that determines whether or not // two strings are equal. // Function declarations bool are_strings_equal( char const str1[], char const str2[] ); int main(); // Function definitions int main() { std::cout << are_strings_equal( "Hi", "Hi there!" ) << std::endl; std::cout << are_strings_equal( "Hi", "Hi " ) << std::endl; std::cout << are_strings_equal( "Hi", "Hi" ) << std::endl; std::cout << are_strings_equal( "This is a sentence.", "This is a sentence." ) << std::endl; std::cout << are_strings_equal( "This is another sentence.", "this is another sentence." ) << std::endl; std::cout << are_strings_equal( "This is a third sentence.", "This is a thrid sentence." ) << std::endl; return 0; } bool are_strings_equal( char const str1[], char const str2[] ) { // Enter your implementation here. return false; } // Hint: You do not have to determine the lengths // of both strings first. // // Remember that every C-style string ends with the // null character '\0'. // Here is one solution: /* bool are_strings_equal( char const str1[], char const str2[] ) { for ( std::size_t k{ 0 }; true; ++k ) { if ( str1[k] != str2[k] ) { return false; } else if ( str1[k] == '\0' ) { // We already know that str1[k] == str2[k]. // Therefore, if str1[k] is the null // character, str2[k] must be as well. assert( str2[k] == '\0' ); return true; } } } */