Write a program that reads two strings and specifies if the two strings are equal or which one is smaller (alphabetically). The program then displays the length of each string.
strcmp() will return zero if the strings are equal but it otherwise it returns a positive or negative number, not necessarily 1 or -1. I'd change your switch statement for something like
1 2 3 4 5 6 7 8 9 10 11 12
if (result > 1)
{
cout << "First string is greater than second string " << endl;
}
elseif ( result == 0)
{
cout << "First string is equal to second string " << endl;
}
else
{
cout << "First string is less than second string " << endl;
}