I have a variable of type LPTSTR
, which I print to std::cout
with <<
. In an ANSI system (don't know exactly where it is determined) it worked fine, it printed the string. Now in a Unicode system I get a hex address instead of the string. So, why does LPSTR
(to which LPTSTR
is resolved if UNICODE
is not defined) act differently from LPWSTR
(... if UNICODE
is defined) and how do I print the string pointed by the latter one?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Do the Java Integer and Double objects have unnece
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
For Unicode strings you want
wcout
.You may be seeing hex because the ANSI/ASCII output stream doesn't know how to handle Unicode characters.
LPTSTR
andLPWSTR
are actually C-isms inherited from the C Windows API days. For C++ I would strongly encourage you to usestd::string
and/orstd::wstring
instead.If you need to roll your own macro, you'll want something like: