
#include <windows.h>
#include <stdio.h>
#include <conio.h>

int main(void) {
    HANDLE screen;
    COORD screenLocation;
    unsigned long int n;
    unsigned short int attribute, attribute_asked;

    screen = GetStdHandle(STD_OUTPUT_HANDLE);

    attribute = 0x74;
    SetConsoleTextAttribute(screen, attribute);
    screenLocation.X = 10; screenLocation.Y = 3;
    SetConsoleCursorPosition(screen, screenLocation );
    printf("A");


    // You can ask the attribute of a screen location 
    // with function ReadConsoleOutputAttribute as follows
    ReadConsoleOutputAttribute(screen, &attribute_asked, 1,
    					screenLocation, &n);

    screenLocation.X = 10; screenLocation.Y = 10;
    SetConsoleCursorPosition(screen, screenLocation );
    printf("Attribuutti is now  %02x", attribute_asked);

    // You can set the attribute in a screen location 
    // with the function WriteConsoleOutputAttribute as follows
    //WriteConsoleOutputAttribute(screen, &attribute_new, 1,
					// screenLocation, &n);
    //so that it takes effect on the screen
   

    return 0;
}
