无限循环
1. 在Windows操作系统中,创建控制台程序child,程序无限循环输出如下格式的文字:“The child is talking at [system time]”
其中的system time是程序获取到的系统时间
提示:使用cout<<ctime(&t1)<<endl;可以输出当前的系统时间(C++);
真的是想不出怎么做。。。
2013-05-28 13:44
程序代码:#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;
int main() {
char tt[30],*p;
p=tt;
time_t t;
while(1)
{
t=time(&t);
p=ctime(&t);
p[strlen(p)-1]='\0';
system("cls");
cout << "The child is talking at [" << p << "]" << endl;
Sleep(1000);
}
return 0;
}
2013-05-28 14:38
2013-05-28 23:01
2013-05-28 23:05