When new project is selected: Win32 Console application
Check the MFC header file support in the wizard to confirm
After you wait for the initialization file to complete, VS2010 automatically opens the project name. cpp File
where int _tmain (int argc, tchar* argv[], tchar* envp[]) This corresponds to the main function
All the contents can be deleted, and finally add a return 0;
MFC common classes: CString class
If you use VS2010, you may see CStringT, which is actually a template class that operates on variable-length strings . The CStringT template class has three instances: CString, CStringA, and CSTRINGW, which provide operations for strings of TCHAR, Char, and wchar_t character types, respectively.
The char type defines ANSI characters, the wchar_t type defines Unicode characters, and TCHAR depends on the configuration of the MFC Project's Properties dialog box properties->general-> Character the Set property, if this property is use Multi-Byte Character set, the TCHAR type defines the ANSI character, and if it is use Unicode Character set, The TCHAR type defines a Unicode character.
Let's look at an example below:
int _tmain (int argc, tchar* argv[], tchar* envp[]) {CString str1 (_t ("www.jizhuomi.com")),//wcout << str1. GetString () << endl;cout << str1. GetString () << Endl;return 0;}
The code above creates a CString object based on the string,
How to Output CString
Because it is wide character, so with Wcout
Because CString is essentially a pointer, and the operator << does not overload the output of CString, the GetString () member function with the CString comes in.
Wcout < <cpath. GetString () < <endl;
The operation of three string classes is the same, except that the character types are handled differently. Chicken Peck Rice to CString class for the explanation object.
Console console using MFC library functions, cout output CString method