在学C++ 用的是C++Primer Plus第六版中文版的书
根据书本P92页代码敲出来后编译运行不了:
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char animal[20] = "bear";
const char *bird = "wren";
char *ps;
cout << animal << " and " << bird << "\n";
cout << "Enter a kind of animal : ";
cin >> animal;
ps = animal;
cout << ps << "!\n";
cout << animal << " at " << (int *) animal << endl;
cout << ps << " at " << (int * ) ps << endl;
ps = new char[strlen(animal) + 1];
strcpy(ps,animal);
cout << "After using strcpy(): \n";
cout << animal << " at " << (int*)animal << endl;
cout << ps << " at " << (int*)ps << endl;
delete[] ps;
return 0;
}