重定向输出流 freopen( " test.txt ", " w ", stdout )
将要输出到终端屏幕上的内容重定向到打印文件test.txt中
重定向输入流 freopen ( " test.txt ", " r ", stdin )
将要从键盘获取的内容重定向到从文件test读取
#include <stdio.h>
int main()
{
int aa=dup(fileno(stdout)); //恢复重定向要用
freopen("test.txt", "w", stdout); //重定向输出为文件
putchar('k');
puts("abcdef"); //不能打印在终端了,会打在文件里
fflush(stdout);
dup2(aa,fileno(stdout)); //恢复重定向
close(aa);
puts("asdfgh"); //又能打印在终端了
return 0;
}
时间
GMT 格林威时间 UTC 世界标准时间
LOCAL TIME 本地时间 EPOCH 纪元点
CLOCK TICK 时钟计时单元 (长短由计算机cpu控制)
时间戳 ; 从1970年1月1日0时0分0秒到当前时间的秒数
获取时间戳
有好几种方法 简单的为time ( 0 ) time (NULL) 常用的为下列方式 time_t t1 time(&t1)
int main()
{
time_t t1;
time(&