PDA

View Full Version : سوال: ساعت سیستم



zuck_619
چهارشنبه 18 فروردین 1389, 22:08 عصر
من تو نوشتن ساعت یه مشکل دارم :
چطوری میشه ساعت سیستم رو خوند و ازش استفاده کرد ؟ ? ?
یعنی میخوام ساعت رو از سیستم بخونم و از دقیقه و ثانیه و زمان به طور جدا استفاده کنم .

tdkhakpur
چهارشنبه 18 فروردین 1389, 22:39 عصر
این کد مربوط به راهنمای خود کامپایلر میشه
دریافت ساعت


#include <stdio.h>
#include <dos.h>
int main(void)
{
struct time t;
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d\n",
t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
return 0;
}

تنظیم ساعت


#include <stdio.h>
#include <dos.h>
int main(void)
{
struct time t;
gettime(&t);
printf("The current minute is: %d\n", t.ti_min);
printf("The current hour is: %d\n", t.ti_hour);
printf("The current hundredth of a second is: %d\n", t.ti_hund);
printf("The current second is: %d\n", t.ti_sec);
/* Add one to the minutes struct element and then call settime */
t.ti_min++;
settime(&t);
return 0;
}