✅ 목표 (Goal)

✅ 경고가 나는 코드


void console_clear_region(int startX, int startY, int width, int height) {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord;
    DWORD charsWritten;
    for (int y = 0; y < height; y++) {
        coord.X = startX;
        coord.Y = startY + y;
        FillConsoleOutputCharacter(hConsole, ' ', width, coord, &charsWritten);
    }
}

✅ 수정된 코드

void console_clear_region(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord;
    DWORD charsWritten;
    // Implicit casts should not lower precision
    for (int cols = 0; cols < height; cols++) {
        // coord.X, Y는 SHORT의 범위(-32,768 ~ 32,767) 내에 있어야 한다.
        coord.X = (SHORT)x;
        coord.Y = (SHORT)(y + cols);
        FillConsoleOutputCharacter(hConsole, ' ', width, coord, &charsWritten);
    }
}

✅ 결론

사실 별거 아니다.

애기하고 싶은 것은 오류를 잡는 방법을 얘기하고자 하는것보다

데이터형에 맞게 코딩하는 습관을 들이자.

나중엠 큰 문제가 생길수 있다.