linux下c语言关机程序
/* Offtimer.c.For auto halt. */
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#define DELAY 60/* Time of sleeping */
int main()
{
time_t now;
struct tm *p;
while(1)
{
now = time(NULL);
sleep(DELAY);/* To reduce cpu occupation */
p = localtime(&now);
if ((p->tm_hour = 14) && (p->tm_min >= 30))/ *This means the system will halt after 14:30 or 14:31 */
system("poweroff"); / *'poweroff' is the command in Red Flag Linux
Desktop 5.0 to turn off the computer.To do this you should be root. */
}
return 0;
}
引用gcc编译,另外需要有root用户的权利才能行。
相关文档:
信号指定处理函数
void (*signal (int signum,void (*handle)(int)))(int);设置某个信号的处理方法
int sigaction(int signum,const struct sigaction *act,struct sigaction *oldact);用于检查或改变进程在接到信号时的动作
信号集操作函数
static inline void sigaddset(sigset_t *set,int _sig);
static inline voi ......
非常基本关于C语言的问题,一个信息类(计算机,资讯工程,电子工程, 通信工程)专业的本科毕业生应该达到的水平。题目不难,全部都能快速地答完,当然也需要一定的知识储备。
对于大多数人,我们预期你可能答错 3) 4) 15)题,所以答错3道以内的,我们认为你很棒
答错5道题以内,我们认为你还不错(你还可能答 ......
MYSQL在 C API 中可用的函数:
mysql_affected_rows()
返回被最新的UPDATE, DELETE或INSERT查询影响的行数。
mysql_close()
关闭一个服务器连接。
mysql_connect()
连接一个MySQL服务器。该函数不推荐;使用mysql_real_connect()代替。
mysql_change_user()
改变在一个打开的连接上的用户和数据库。
mysql_ ......
#include <Windows.h>
#include <math.h>
#include "resource.h"
#define PI 3.1415976/180
int dwCenterX,dwCenterY,dwRadius;
const TCHAR *szAppName=TEXT("Clock");
LRESULT CALLBACK ProcWinMain(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
void ShowTime(HWND hwnd,HDC hdc);
void ......