Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output unicode symbol π and ≈ in c++ win32 console application

I am fairly new to programming, but it seems like the π(pi) symbol is not in the standard set of outputs that ASCII handles.

I am wondering if there is a way to get the console to output the π symbol, so as to express exact answers regarding certain mathematical formulas.

like image 668
Dominic A. Graham Avatar asked Jan 17 '13 09:01

Dominic A. Graham


1 Answers

I'm not really sure about any other methods (such as those that use the STL) but you can do this with Win32 using WriteConsoleW:

HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
LPCWSTR lpPiString = L"\u03C0";

DWORD dwNumberOfCharsWritten;
WriteConsoleW(hConsoleOutput, lpPiString, 1, &dwNumberOfCharsWritten, NULL);
like image 60
Adam Maras Avatar answered Sep 28 '22 09:09

Adam Maras