// shows strings represented in memory as char array + terminator // shows cout printing string instead of address for char array #include #include using namespace std; void subr (int* ip); int main() { char ar[10] = "wxyz"; char* ip; cout << "The string " << ar << " has length " << strlen(ar) << endl << endl; // Let's give the string a new value // Why can't we say this? ar = "abcde" strcpy(ar, "abcde"); cout << "The string " << ar << " has length " << strlen(ar) << endl << endl; // We can make the string shorter too strcpy(ar, "qq"); cout << "The string " << ar << " has length " << strlen(ar) << endl << endl; // Let's violate data abstraction (NOT recommended) ar[2] = 'z'; cout << "The string " << ar << " has length " << strlen(ar) << endl << endl; return 0; } /* output: The string wxyz has length 4 The string abcde has length 5 The string qq has length 2 The string qqzde has length 5 */