在第七单元中,程序清单7.10 strgback.cpp,部分如下:
#include<iostream>
char * buildstr(char c, int n); // prototype
int main()
{
using namespace std;
int times;
char ch;
cout << "Enter a character: ";
cin >> ch;
cout << "Enter an integer: ";
cin >> times;
char * ps = buildstr(ch, times);
cout << ps << endl;
delete [] ps ; // free memory
ps = buildstr('+', 20); // refuse pointer
cout << ps << "-Done-" << ps << endl;
delete [] ps; // free memory
system("pause");
return 0;
}