abt时间功能 [英] abt time functions

查看:112
本文介绍了abt时间功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我想知道如何使用 - system(date)显示没有

的系统时间。

任何人都可以给我这个操作的想法。


By

SSG

Hi All!
I want to know how to display the system time without
using--system("date").
can anyone give me the idea to handle this operation.

By
S.S.G

推荐答案

hi ssg,

这是使用显示日期和时间的程序..

#include< stdio.h>

#include< stdlib.h>

#include< time.h>

int main(无效)

{

// system(" date");

time_t rt;

struct tm * ti; //这个结构的所有int变量都是tm

成员...喜欢tm_hour

char * p;

time(& rt) ; //这一个返回0:0:0 gst 1979

ti = localtime(& rt); //获取本地时间存储到tm结构

printf(当前日期和时间是:%s,asctime(ti));

//转换日期结构to string

printf("%d ::%d ::%d",ti-> tm_hour,ti-> tm_min,ti-> tm_sec); //只需

使用该结构

}


By

Sree Krishna

太多半导体解决方案

印度

hi ssg,
this is program using display date and time ..
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
// system("date");
time_t rt;
struct tm * ti; // this structure have all int variable of tm
members... like tm_hour
char *p;
time (&rt); // this one return 0:0:0 gst 1979
ti = localtime ( &rt ); // get local time store to tm structure
printf ( "Current date and time are: %s", asctime (ti) );
//converting date structure to string
printf ("%d::%d::%d",ti->tm_hour,ti->tm_min,ti->tm_sec); //simply
using that structure
}

By
Sree Krishna
TooMuch Semiconductors Solutions
INDIA


chellappa写道:
chellappa wrote:
hi ssg,<这是使用显示日期和时间的程序..
#include< stdio.h>
#include< stdlib.h>
#include< time.h>
int main(void)
// system(" date");
time_t rt;
struct tm * ti; //这个结构的所有int变量都是tm
成员...就像tm_hour
char * p;


这是做什么的?

时间(& rt); //这一个返回0:0:0 gst 1979


嗯?

这里没有检查错误。

ti =当地时间(& rt); //获取本地时间商店到tm结构


不检查错误。

printf(当前日期和时间是:%s,asctime( ti));


格式字符串末尾需要\ n。

//将日期结构转换为字符串
printf("%) d ::%d%::&d QUOT;,&TI-GT; tm_hour,TI-> tm_min,TI-> tm_sec); //简单地


再次,你需要格式字符串末尾的\ n。

为什么双冒号?

使用该结构
}
hi ssg,
this is program using display date and time ..
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
// system("date");
time_t rt;
struct tm * ti; // this structure have all int variable of tm
members... like tm_hour char *p;
What is this doing here?
time (&rt); // this one return 0:0:0 gst 1979
Huh?
No check for error here.
ti = localtime ( &rt ); // get local time store to tm structure
No check for error.
printf ( "Current date and time are: %s", asctime (ti) );
You need a \n at the end of your format string.
//converting date structure to string
printf ("%d::%d::%d",ti->tm_hour,ti->tm_min,ti->tm_sec); //simply
Again, you need a \n at the end of the format string.
Why the double colons?
using that structure
}




Robert Gamble



Robert Gamble


SSG写道:
大家好!
我想知道如何在没有使用系统(日期)的情况下显示系统时间。
任何人都可以给我想要处理这个操作。
Hi All!
I want to know how to display the system time without
using--system("date").
can anyone give me the idea to handle this operation.




请获得一本小学C课本。如果你没有
买不到它,请使用库中的那个。


#include< stdio.h>

#include< time.h>


int main(无效)

{

time_t now = time(0) ;

printf(时间是%s,ctime(& now));

返回0;

}



Please get an elementary C textbook. Use the one in the library if you
can''t afford one.

#include <stdio.h>
#include <time.h>

int main(void)
{
time_t now = time(0);
printf("The time is %s", ctime(&now));
return 0;
}


这篇关于abt时间功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆