The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.

Pstrings are Mutable

You can change the letters in an pstring one at a time using the [] operator on the left side of an assignment. For example,

  pstring greeting = "Hello, world!";
  greeting[0] = 'J';
  cout << greeting << endl;

produces the output Jello, world!.

Last Update: 2005-12-05