C++ Pointer access character within string via pointer
#include <iostream> using namespace std; int main()//from w w w. j ava 2 s. c o m { string s; string *ptrToString; s = "this is a test from book2s.c o m"; ptrToString = &s; for (unsigned i = 0; i < s.length(); i++){ cout << (*ptrToString)[i] << " "; } cout << endl; return 0; }