Hey guys,

i am writing a couple of programs but I have some problem with the basic one...

can you please provide me with a 24 hour clock which has hour, minute and second? also it should have the ability to set the time..

your help is highly appreciated...it is somehow urgent as i need to do the other programs based on this....

2
Contributors
6
Replies
8
Views
8 Years
Discussion Span
Last Post by Ancient Dragon

It's pretty simple, just create an infinite loop. Inside the loop get current time ( time() in time.h ), convert to tm structure ( localtime() ), then just print the hour, minute, and second).

How to set the computer's clock will depend on the operating system.

hey dragon.
i want a program by which you can set and adjust the time...
consider your watch...it has two buttoms and now you want to set the hour, min, sec...
i want a program like this...
i worked alot on a for loop but nothing happens...
pls give me complete information as i am a beginner...
you should use one or two buttoms to set the time...for example when u set the hour, it should go to min, and after you set min, it should go to second...
obviously hour should be 23 by maximum and again after 23 it should go to zero...(or it can be in am-pm)
minute, second should be 59 by maximum and again after 59 it should go to zero....

i have no idea how i can use two buttoms for setting three values...i want to set hour, min, sec...

can u check if this is right for hour?

``````while(hour<24)
{
press buttom 2;(it is not important how i tell to press the buttom)
hour++;
if(hour>=24)
hour=0;
}``````

is this right for setting th hour?
then after i set the hour how i can set the min and second?

Edited by Nick Evan: Added code-tags

hey dragon.
i want a program by which you can set and adjust the time...
consider your watch...it has two buttoms and now you want to set the hour, min, sec...
i want a program like this...
i worked alot on a for loop but nothing happens...
pls give me complete information as i am a beginner...
you should use one or two buttoms to set the time...for example when u set the hour, it should go to min, and after you set min, it should go to second...
obviously hour should be 23 by maximum and again after 23 it should go to zero...(or it can be in am-pm)
minute, second should be 59 by maximum and again after 59 it should go to zero....

Writing such a program is no trivel matter. If you are a beginner in C language then you have no business attempting that. Instead, learn the basics of the language first, then once you are comfortable with it you can branch out into gui programs, such as win32 api, xwindows, wxWidgets, etc. I would even forget going that program in C language and use C# or C++/CLR (Windows Forms) instead. C language is not a good choice anymore for gui programming.

but i need it in C although i am a beginner....

but i need it in C although i am a beginner....

There are only two ways to get it like that:

1. Pay someone to write it for you. That will cost you some \$\$\$
2. Learn to write it yourself.

I have not the time to write it for you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.