#include <iostream>
#include <cstring>
using namespace std;
bool equalStrings (char[], char[]); //given here but must complete
                                  // on midterm

int main()
    char str1[80];
    char str2[80];
    cout << "Enter your first string: " << endl;
    cout << "Enter your second string: " << endl;
    if (equalStrings (str1, str2) ) //on mt fill in call
        cout << "The two strings are identical." << endl;
        cout << "The two strings are NOT identical." << endl;

//Write the function header and body of equalStings

Sample Runs;

Enter your first string; hello--- //-means blank
Enter you second string; hello
The two strings are NOT identical

Sample Runs;
Enter your first string; jon
Enter you second string; joN
The two strings are NOT identical

Sample Runs;
Enter your first string; jane doe
Enter you second string; jane doe
The two strings are identical

Edited by Reverend Jim: Fixed formatting

13 Years
Discussion Span
Last Post by Narue

>use memcmp
Brilliant! No, not really. If not being able to use strcmp is a requirement of the function then clearly it's homework and using memcmp would result in a failing grade.

However, I won't make a suggestion other than looping over the contents of both arrays and making comparisons because the OP didn't show an honest attempt at writing the function. It isn't terribly difficult if you expend a little energy trying.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.