I'm coding an application, and want to print underlined text. What I'm doing wrong?
I'm using a "translated" code from C#, normally it works great in C# but does not in C++. After I fixed the errors, the code simply does not work. It shows some characters that normaly won't. This is what it prints instead (https://i.stack.imgur.com/qAPPQ.png)
Here's the code I used
auto DllHandler = GetStdHandle(-11);
unsigned int Mode;
GetConsoleMode(DllHandler,PDWORD(Mode));
Mode |= 4;
SetConsoleMode(DllHandler,DWORD(Mode));
cout << "\x1b[5mUnderlined \x1b[0mtext" << endl;
And here's the original (C#) code:
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
[DllImport("kernel32.dll")]
public static extern IntPtr SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
var DllHandler = Kernel32.GetStdHandle(-11);
uint Mode;
GetConsoleMode(DllHandler,out Mode);
Mode |= 4;
SetConsoleMode(DllHandler, Mode);
Console.Write("\x1b[5mUnderlined \x1b[0mText");
Thanks in advance.