C时钟:时间点亮

对于学校我必须做一个任务,我现在忙着它已经有3个星期了,但仍然没有走得太远。 我们需要制作一个必须是圆形的时钟,并且需要点亮秒数和小时的颜色。 所以,如果是凌晨4点25分,这些数字需要点亮。

这就是我现在所拥有的:

#include  #include  #include  #include  #include  #include  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; } 

谁能告诉我怎么可能这样做? 我不是要你做我的作业..我真的需要一些帮助。

好的,所以基于你的评论听起来你正在使用Windows而你真的只想设置一种颜色。 这很简单。 你想要SetConsoleTextAttribute()函数,这是一个非常快速的例子:

 #include  #include  #include  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 } 

为了进一步突出显示,你也可以改变背景,你可以通过OR( | )标记来获得不同的颜色和不同的背/前场。

因此,如果您想在绿色背景上做红色文字(出于某种原因),您可以这样做:

 FOREGROUND_RED | BACKGROUND_GREEN 

在此处输入图像描述

我认为这就是你真正想要的,现在你可以把它拿到你的时钟上,花时间和突出颜色。