I wrote a program that compares two strings and tests to see if they are the same. Case difference doesn't matter. The problem is this: When the program is run it works only half the time. The other half the program doesn't wait for the second string to be entered, it just skips that part and compares the strings. I can't figure out why it is doing this.
Please help.
Also any comments to tighten up my code would be appreciated.
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char str_arr1[80], str_arr2[80];
int x;
cout << "Please enter your first string\n";
cin >> str_arr1;
cout << "Please enter your second string\n";
cin >> str_arr2;
//Converts all the characters in the first array to lower case
for(x=0; str_arr1[x]; x++) str_arr1[x] = tolower(str_arr1[x]);
//Converts all the characters in the second array to lower case
for(x=0; str_arr2[x]; x++) str_arr2[x] = tolower(str_arr2[x]);
if(!strcmp(str_arr1, str_arr2))
cout << "The strings MATCH\n";
else
cout << "The strings DO NOT MATCH\n";
system("pause");
return 0;
}