CString filename = "myfile.txt"; CString first_three = filename.Left(3); // first_three now contains "myf"
CString user_input; std::cin >> user_input; CString first_two = user_input.Left(2); // first_two now contains the first two characters of user_inputThe CString Left function is part of the MFC (Microsoft Foundation Class) library, which is included in Microsoft Visual Studio. It is also available in the ATL (Active Template Library) library for Windows programming.