+ 3
How to make a working digital clock program in C language
Did we make a working digital clock program using C language if yes then how . Please submit your answer if you know it , because I tried to make clock program but I failed.
1 Resposta
+ 2
The first thing you want to need to know is getting familiar with the provided structure in the <time.h> library called `tm` which consists of almost all necessary fields to work with time and date entities.
struct tm
{
int tm_sec; /* Seconds: 0-61 (until C99) / 0-60 (since C99) */
int tm_min; /* Minutes: 0-59 */
int tm_hour; /* Hours since midnight: 0-23 */
int tm_mday; /* Day of the month: 1-31 */
int tm_mon; /* Months *since* january: 0-11 */
int tm_year; /* Years since 1900 */
int tm_wday; /* Days since Sunday (0-6) */
int tm_yday; /* Days since Jan. 1: 0-365 */
int tm_isdst; /* +1 Daylight Savings Time, 0 No DST, -1 don't know */
};
As an example, to retrieve the current "local" system time and date as a formatted string we might do it this way (it requires to get run on a local compiler installed on a machine otherwise it shows the current Greenwich Mean Time (GMT))
http://www.cplusplus.com/reference/ctime/localtime/