mardi 4 février 2020

Win32 API console cursor not moving after WriteConsole

So, when I try to read a std::wstring from the console with this code

std::wstring string;
wchar_t c;
DWORD u;
do {
    ReadConsole(GetStdHandle(STD_INPUT_HANDLE), &c, 1, &u, NULL);
} while (u && (c == L' ' || c == L'\n'));
do {
    string.append(1, c);
    ReadConsole(GetStdHandle(STD_INPUT_HANDLE), &c, 1, &u, NULL);
} while (u && c != L' ' && c != L'\n');

WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), string.data(), string.length(), &u, NULL);

After writing the string the cursor position does not move and so if I call again WriteConsole(), it will write above the just written string. Is there any solution to this?

Aucun commentaire:

Enregistrer un commentaire