I'm looking for a way to use SetConsoleTextAttribute() to reset the output color of the windows console, doing what \033[0m
does on Mac and Linux. Is there any way of doing this? I'm looking to avoid external libraries and instead just use windows.h
CodePudding user response:
I don't think there is a reset function, you just have to save the attributes when your program starts.
To determine the current color attributes of a screen buffer, call the GetConsoleScreenBufferInfo function.
cmd.exe works the same way:
color 09
cmd /k
color&rem still blue because this instance started blue
exit
color&rem restored now
Also, don't forget to use SetConsoleCtrlHandler
to restore the color on Ctrl C.