c++ - How to use WriteConsoleOutputAttribute function correctly -
why following code
const std::string text = "str"; handle stdout_handle = getstdhandle(std_output_handle); coord coords = { 0, 0 }; dword written = 0; writeconsoleoutputcharactera(stdout_handle, text.c_str(), text.size(), coords, &written); word attributes = foreground_green; writeconsoleoutputattribute(stdout_handle, &attributes, text.size(), coords, &written);
results in this:
what doing wrong? how can fix it?
&attributes
points array of length one, single green attribute. claim array text.size()
long. result, copy random stack content next 2 cells. happens red-on-red.
solution:
std::vector<word> attributes(text.size(), foreground_green); writeconsoleoutputattribute(stdout_handle, &attributes[0] ...
Comments
Post a Comment