Self new textbooks --p60_5_1

Source:

#include <iostream>

#include <string>

using namespace std;

int main ()

{

  int n,i;

  cout << "enter several strings:";

  cin >> n;

  string *p;

  string *A = new string[n];

  p = A;

  cout << endl;

  cout << "Please enter:";

  for (i = 0; i < n; i++)

    cin >> A[i];

  p = A; // pointer to the first address of the array redirect

  cout << endl;

  cout << "you enter a string:";

  for (i = 0; i < n; i++)

    cout << p[i]<<endl;

  delete []p;

  system("pause");

  return 0;

}

operation result:

Guess you like

Origin www.cnblogs.com/duanqibo/p/11974621.html