// Program file: strcompcat.cpp // Demo char array functions #include using namespace std; int main() { char name1[11], name2[11], twoNames[25]; int order; char sign; system("cls"); cout << "Enter the first name: "; cin >> name1; cout << "Enter the second name: "; cin >> name2; cout << name1 << " " << name2 << endl; cout << &name1 << " " << &name2 << endl; // Equal operator compares addersses not values if (name1 == name2) cout << "Strings equal" << endl; else cout << "Strings are not equal" << endl; order = strcmp(name1, name2); if (order < 0) { sign = '<'; cout << order << endl; } else if (order > 0) { sign = '>'; cout << order << endl; } else { sign = '='; cout << order << endl; } cout << name1 << " " << sign << " " << name2 << endl; // name2 = name1; // illegal use of assign operator strcpy(name1, name2); cout << "name1 is " << name1 << " and name2 is " << name2 << endl; // concatenate two strings to one strcpy(twoNames, "Emily"); strcat(twoNames, " "); strcat(twoNames, name2); cout << "The two names together are " << twoNames << endl; cout << "The length of the two names is " << strlen(twoNames) << endl; system("pause"); return 0; }