📄 justtest.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
void print_time()
{
struct timeval tp;
struct tm t_m;
gettimeofday (&tp, NULL);
t_m = *localtime( &tp );
printf("TIME -- %d:%d:%d:%f:%f [1 ms:0 us]\n",
t_m.tm_hour,t_m.tm_min, t_m.tm_sec, tp.tv_usec/1000,tp.tv_usec);
}
int main(void)
{
int i=10;
struct timeval timeout;
printf("----------- test sleep -----------\n");
while (i>0) {
sleep(1);
print_time();
i--;
}
printf("----------- test select -------------- \n");
i=100;
while (i>0) {
i--;
timeout.tv_sec = 0;
timeout.tv_usec = 2000;
select(FD_SETSIZE,NULL,NULL,NULL,&timeout);
print_time();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -