I use visual studio 2012 and i would like an easy way to print out → on windows console using
cout.
if it's not possible with cout then something else.
Asked
Active
Viewed 100 times
0

Constantine
- 763
- 2
- 9
- 19
-
Personaly, I'd just settle for `cout << "-->";` :) – jrok Jun 18 '13 at 23:06
-
yeah but what if i want ↓ – Constantine Jun 18 '13 at 23:09
1 Answers
2
You want to use the Wide-Character version of cout
, which is called wcout
. It can print wide character strings, but you must put L
before the string to declare it wide character.
MSDN Website
std::wcout << L"→";

built1n
- 1,518
- 14
- 25
-
Hah, it gets separated on [Coliru](http://coliru.stacked-crooked.com/view?id=eb1b973d58b466469ce3907a6124e842-1dfa45f65786f4a26064bc85b3de325a) :p – chris Jun 18 '13 at 23:06
-
-
@Kostas, It works fine, it's just the console's inability to display it. Put it in a call to `MessageBoxW` and watch it magically work there. – chris Jun 18 '13 at 23:09
-
can you write exactly the part where i use messageboxw because i have no idea how to... – Constantine Jun 18 '13 at 23:13
-
@Kostas, There are tons of examples. And it's probably not what you want, it was just to show you that the code works when displayed by something that can handle these characters. – chris Jun 18 '13 at 23:17
-
@Kostas: (1) `#include
`. (2) `MessageBoxW (NULL, L"→↓", L"...", MB_OK);`. – yzt Jun 18 '13 at 23:20 -
ah i see now what message box is, though i would like a way for it to work on the console :/ – Constantine Jun 18 '13 at 23:22
-
@Kostas: You might want to read this too: http://stackoverflow.com/questions/1371012/how-do-i-print-utf-8-from-c-console-application-on-windows , but keep in mind that UTF-8 is different from the kind of Unicode characters that `L"whatever"` gives you. – yzt Jun 18 '13 at 23:25