The following code shows you how to print CString to cout.
#include "atlstr.h" #include <iostream> using namespace std; int main () { // Create a CString CString cStr = _T("I am a CString."); // Print the address of cStr only cout << cStr << endl; // Print the cStr content wcout << cStr.GetString() << endl; // Pause system("PAUSE"); // Terminate the program: return 0; }
You will get the following output.
Please note that you have to include atlstr.h before you can utilize the CString object.
Done =)
Reference: CString will not go to cout