Two more tips.
(1) Precompiled header. "stdafx.h"
Basically, this is the place where you put all standard library include
directives that will be needed by your code.
Examples:
// OS includes
#include
// C includes
#include
// C++ STL includes
#include
#include
Try not to include any of your own header files in "stdafx.h", until you are
familiar with the Visual C++ build process.
Never modify "stdafx.cpp". It is required to be an empty file containing
just the #include "stdafx.h" and nothing else.
Visual C++ requires the use of precompiled header. Not using precompiled
header in a Visual C++ project is considered an advanced configuration, so
this choice is not recommended for learners.
If you need to compile C source files into a Visual C++ project: you can
either add the #include "stdafx.h" to the C source file, or you can change
the per-source-file configuration.
(2) integer sizes, and using wchar_t strings with STL.
On Visual C++:
char is 8-bit.
wchar_t is 16-bit.
int is 32-bit.
long is 32-bit. (This is true for both 32-bit and 64-bit applications.)
size_t is 32-bit on 32-bit applications, and 64-bit on 64-bit applications.
sizeof(void*) is 4 on 32-bit applications, 8 on 64-bit applications.
For strings, use std::wstring, std::wcin, std::wcout, std::wcerr, std::
wstringstream, std::wifstream, std::wofstream, ...
Most Windows API functions have "narrow string vs. wide string" versions.