For school I have to do a assignment, Im busy with it for like 3 weeks now and still havn’t gotten far. We need to make a clock that has to be round and the colours of the seconds minutes AND hours need to light up. So if it’s 4:25 am those numbers need to light up.
This is what I’ve got right now:
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include <unistd.h>
#include <stdlib.h>
#include <windows.h>
int csecs (int cseconds );
void main (int sec, int min){
printf("Hallo! Veel plezier met het bekijken van de tijd!");
getch();
while (sec)
{
time_t cseconds;
cseconds = time (NULL);
printf ("De Tijd: ");
printf ("%d:", csecs( cseconds )/60/60%24+1);
printf ("%d:", csecs( cseconds )/60%60 );
printf ("%d", csecs( cseconds )%60 );
Sleep(1000);
system("cls");
}
}
int csecs (int cseconds)
{
return cseconds;
}
Can anyone tell me how I could possibly do this? I’m not asking you to do my homework.. I just really need some help.
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:
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:
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.