No matter what the strings are this program always reads them as different strings...
Code:
#include <iostream>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char string1[20], string2[20];
cout<<"Input 2 strings. This program will tell you if the 2\n strings are excactly the same ";
cin.getline(string1, 20);
cout<<'\n';
cin.getline(string2, 20);
cout<<"The 2 strings you entered were "<<string1<<" and "<<string2<<'\n';
strcmp(string1, string2);
if(string1 == string2)
{
cout<<"The two strings you entered are the same";
}
if(string1 != string2)
{
cout<<"The two strings you entered are not the same";
}
system("PAUSE");
return 0;
}
Can someone explain why this isnt working and what i need to do to get it to work? Thankyou.