Clock in C: Time light up [closed]

◇◆丶佛笑我妖孽 提交于 2019-12-06 01:02:42

OK, so based on your comments it sounds like you're using Windows and you really just want to set a color. That's pretty easy. You want the SetConsoleTextAttribute() function, here's a very quick example:

#include <stdio.h>
#include <Windows.h>
#include <string.h>

void main()
{
    printf("Hello\n");  // Print white text on black output
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
    printf("Hello Again!\n");  // Print Red text on black output
    getchar(); // Pause the program to admire the colors
}

For further highlighting you can also change the back ground, you can OR (|) together flags to get different colors and different back/fore grounds.

So if you wanted to do red text on a green back ground (for some reason) you could do:

FOREGROUND_RED | BACKGROUND_GREEN

I think that's all you were really asking for, now you can take that and apply it to your clock, getting the time and highlighting the color.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!