char name[] = "John Doe"; CString str(name); CString substr = str.substr(5, 3);
CString message = "The quick brown fox"; CString substr = message.substr(4);In this example, we create a CString object "message" and use the substr function to extract the substring starting at index 4 until the end of the string, which should return "quick brown fox". These examples use the MFC (Microsoft Foundation Classes) library, which includes the CString class.