#include #include // c-string function declarations using namespace std; int main() { char s1[5] = "bass"; // need space of null terminator char s2[15] = "guitar"; char s3[20]; // returns 4 NOT 5 int len = strlen(s1); // outputs a negative number, s1 comes before s2. cout << strcmp(s1, s2) << endl; // outputs 0, they are the same cout << strcmp(s1,s1) << endl; // outputs a positive number cout << strcmp(s2,s1) << endl; // copy s2 in s3, including null character, return s3 strcpy(s3,s1); cout << "s3 is " << s3 << endl; // append " " at the end of s3 strcat(s3, " "); // append "guitar" at the end of s3 // Always make sure there is enough room to append. // Results are unpredictable during runtime. strcat(s3, s2); cout << "s3 is " << s3 << endl; system("pause"); return 0; }