时钟在C:时间补光灯

编程入门 行业动态 更新时间:2024-10-10 19:24:38
本文介绍了时钟在C:时间补光灯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有关学校里,我必须做一个分配而言,我忙着它样3周了,仍然没有带变得远。我们需要有是圆的钟的秒分钟和小时的颜色要亮起来。所以,如果是上午04时25这些数字需要亮起来。

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.

这是我有现在:

#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.

推荐答案

好了,根据您的意见听起来好像你正在使用Windows,你真的只是想设置一个颜色。这是pretty容易。您希望SetConsoleTextAttribute()函数,这里是一个非常简单的例子:

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 }

有关进一步凸显你也可以改变回地面,可以OR( | )一起标记来获得不同的颜色和不同的背/脱颖而出的理由。

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.

更多推荐

时钟在C:时间补光灯

本文发布于:2023-11-27 14:20:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638430.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时钟   光灯   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!