how to change color ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    #include <windows.h>
    void gotoxy(int x,int y);
    int main()
    {
    int i;
    int y=6;
    int x=9;
    for(i=1;i!=0;i++)
    {
    system("color 1");
    sleep(500);
    gotoxy(x,y);
    printf("%d",i);
    }
    getch();
    }
    void gotoxy(int x,int y)
    {
    COORD coord = {x,y};
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
    }


How to change the color when the number changes ? And the color must be according to the
color attribute of console output.
Topic archived. No new replies allowed.