#include #include #include #include using namespace std; main(int argc, char **argv) { char *s; string str; const char *str_tmp; int i; if (argc != 2) { cerr << "usage: stringhelp word\n"; exit(1); } s = argv[1]; str = argv[1]; str[0] = 'J'; cout << "After changing str[0] to J: argv[1] = " << argv[1] << ", str = " << str << " and s = " << s << endl; s[0] = 'P'; cout << "After changing s[0] to P: argv[1] = " << argv[1] << ", str = " << str << " and s = " << s << endl; cout << endl; cout << "Memory pointers:\n\n"; printf("%15s: 0x%lx\n", "argv[1]", argv[1]); printf("%15s: 0x%lx\n", "s", s); printf("%15s: 0x%lx\n", "str.c_str()", str.c_str()); }