In visual studio 2015 environment, I just made simple Win32 console application program project to study MFC. (Also, I check on adding common header file of MFC in project Wizard process)
And Here is main part of this project..
#include "stdafx.h"
#include "Practice02.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CWinApp theApp;
using namespace std;
int main()
{
int nRetCode = 0;
HMODULE hModule = ::GetModuleHandle(nullptr);
if (hModule != nullptr)
{
if (!AfxWinInit(hModule, nullptr, ::GetCommandLine(), 0))
{
wprintf(L"error: sample\n");
nRetCode = 1;
}
else
{
CString temp(L"Hello");
cout << temp << endl;
}
}
else
{
wprintf(L"Fatal Error: GetModuleHandle failure\n");
nRetCode = 1;
}
return nRetCode;
}
My intention is to make simple program which prints CString object containing "hello" value on cmd screen.
However, after start this project, I only see the address value of this object. (EX. 0039841 or 003913E1 etc...)
Where should I modify this code to print real value of CString object?
_UNICODEdefined, print towcoutinstead.#include <atlstr.h>and#include "windows.h"then you can useCStringand WinAPI functions. You won't be able to use other MFC functions. RemoveCWinApp theApp;, removeAfxWinInit...std::ostreamhas an overload for several pointer types. By default, it uses thevoid const*overload which then prints the hex-formatted address. Now, try to find out to which type yourCStringconverts, e.g. by stepping through it with a debugger.