⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 这是linux下的基础C编程代码。都是已经调试成功的
💻 C
字号:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/file.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <signal.h>
#include <pthread.h>

long TIME_OUT=0;

long get_time()  
{  
	long int secondTime=0;
	struct tm *currtime;
	time_t now;  

	time(&now);  
	//time函数读取现在的时间(国际标准时间非北京时间),然后传值给now  
	currtime=(struct tm *)localtime(&now);   
	//localtime函数把从time取得的时间now换算成你电脑中的时间(就是你设置的地区) 
    printf("now time is :%02d%02d%02d\n",currtime->tm_hour,currtime->tm_min,currtime->tm_sec);
	
    secondTime=(24-currtime->tm_hour-1)*60*60+(60-currtime->tm_min-1)*60+(60-currtime->tm_sec);
	return secondTime;
} 

void clean_up_interim_card(int signum)
{
   TIME_OUT=24*60*60;
   alarm(TIME_OUT);
   printf("now is 0:00, clean up interim card\n");
}

void alarm_at_special_time()
{  
	signal(SIGALRM, clean_up_interim_card); // 设置SIGALRM信息的处理函数
	TIME_OUT=get_time();
	alarm(TIME_OUT);	                    // 设置定时器
}

int main()
{
   alarm_at_special_time();
   while(1){;}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -