123456789101112
#include <iostream> using namespace std; int main() { char word1[]="hello",word2[]="hello" if(word1==word2) cout<<"word1 equals word2"; else cout<<"word1 does not equal word2"; }
1234567891011121314151617
#include <iostream> #include <cstring> using namespace std; int main() { char word1[] = "hello"; char word2[] = "hello"; if(!strcmp(word1, word2)) cout << "word1 equals word2"; else cout << "word1 does not equal word2"; return 0; }