64,639
社区成员
发帖
与我相关
我的任务
分享
/*
测试系统时间输入输出。
2014年6月20日 23:29:30
-------------------------
功能:想达到调用windows.h中system中的time函数。
未实现。
*/
#include<iostream>
#include<math.h>
#include<string.h>
#include<windows.h>
#include<time.h>
using namespace std;
struct time /* Gets system time */
{
time_t t;
while(1)
{
time(&t);
Sleep(1000);
system("cls");
cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl;
}
}tm;
int main( int argc, char *argv[] )
{
int year;int month;int day;
int h;int min; int s;
cout<<"系统时间日期 时间 显示。请用输入后加空格"<<endl;
cout<<"请输入系统日期:"<<endl;
cin>>year >>month >>day;
cout<<"请输入系统时间:"<<endl;
cin>>h >>min >>s;
printf("-----------------------------------------------------\n");
printf("- -\n");
printf("- 系统日期: -\n");
printf("- %d年%d月%d日 -\n",year,month,day);
printf("- 系统时间: -\n");
printf("- %d时%d分%d秒 -\n",h,min,s);
printf("- -\n");
printf("-----------------------------------------------------\n");
return 0;
}
/*
测试系统时间输入输出。
2014年6月20日 23:29:30
-------------------------
功能:想达到调用windows.h中system中的time函数。
未实现。
*/
#include<iostream>
#include<math.h>
#include<string.h>
#include<windows.h>
#include<time.h>
using namespace std;
struct mytime /* Gets system time */
{
time_t t;
mytime()
{
while(1)
{
Sleep(1000);
system("cls");
char szCurrentDateTime[32];
time_t nowtime;
struct tm* ptm;
time(&nowtime);
ptm = localtime(&nowtime);
sprintf(szCurrentDateTime, "%4d-%.2d-%.2d %.2d:%.2d:%.2d",
ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,
ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
cout<<"Today's date and time:"<<endl<<szCurrentDateTime<<endl;
}
}
}tm;
int main( int argc, char *argv[] )
{
struct mytime tt;
return 0;
}
struct time /* Gets system time */
{
time_t t;
while(1)
{
time(&t);
Sleep(1000);
system("cls");
cout<<"Today's date and time:"<<endl<<ctime(&t)<<endl;
}
}
这能通过编译?