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用户的权利才能行。
相关文档:
Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......
前言,Linux/Unix 社区的版块不热闹,新手太多,高手太忙,偶把自己这几年的Linux学习的过程讲讲,希望能给大家有点帮助,
引导初学者学习的方向,少走弯路,事半功倍,同时也是抛砖引玉,请过来人热烈发言。
1. 首先熟悉 Linux
建议在 Windows 上安装 VMware Workstation 6.5.0(以下简称VM), 下载种子在 ......
C,C++网络编程学习简明指南
1. 扎实的C,C++基础知识
参考资料《C程序设计》,《C++ primer》。
2. TCP/IP协议
经典书是:W.Richard Stevens 著《TCP/IP详解》三卷书,卷1是协议,卷2是实现,卷3是TCP事务协议等。还有官方的协议文档:RFC
当然也可以在网上下载电子书。
经典的开源协议分析工具:Wireshark.
......
#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 ......
编译,编译程序读取源程序(字符流),对之进行词法和语法的分析,将高级语言指令转换为功能等效的汇编代码,再由汇编程序转换为机器语言,并且按照操作系统对可执行文件格式的要求链接生成可执行程序。
C源程序头文件-->预编译处理(cpp)-->编译程序本身-->优化程序-->汇编程序-->链接程序--> ......