CString str = "Hello, world!"; LPCTSTR lpStart = str.GetParsePointer(); while (*lpStart) { // do something with character at lpStart lpStart++; }
CString str = "Hello, world!"; LPCTSTR lpStart = str.GetParsePointer(); while (*lpStart) { if (*lpStart == 'o') { *lpStart = 'O'; // change 'o' to 'O' } lpStart++; } TRACE("%s", str);In this example, we are again iterating over the string by getting a pointer to the internal character buffer using `GetParsePointer()`. However, this time we are also changing the characters of the string by dereferencing the pointer and modifying the value. We then output the modified string using TRACE. Overall, `CString GetParsePointer` is a convenient method to use when parsing or manipulating strings in MFC/C++ applications.