2012年4月26日

sscanf

摘要: sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: int sscanf( const char *, const char *, ...); int sscanf(const char *buffer,const char *format,[argument ]...); buffer 存储的数据 format 格式控制字符串 argu... 阅读全文

posted @ 2012-04-26 16:56 D_D_U 阅读(336) 评论(0) 推荐(0) 编辑

2012年4月25日

编写Linux/Unix守护进程

摘要: 守护进程在Linux/Unix系统中有着广泛的应用。有时,开发人员也想把自己的程序变成守护进程。在创建一个守护进程的时候,要接触到子进程、进程组、会晤期、信号机制、文件、目录和控制终端等多个概念。因此守护进程还是比较复杂的,在这里详细地讨论Linux/Unix的守护进程的编写,总结出八条经验,并给出应用范例。 编程要点 1.屏蔽一些有关控制终端操作的信号。防止在守护进程没有正常运转起来时,控制终端受到干扰退出或挂起。示例如下: signal(SIGTTOU,SIG_IGN); signal(SIGTTIN,SIG_IGN); signal(SIGTSTP,SIG_IGN); signal... 阅读全文

posted @ 2012-04-25 17:45 D_D_U 阅读(697) 评论(0) 推荐(0) 编辑

2012年4月24日

strlen

摘要: function strlen <cstring> size_t strlen ( const char * str );Get string lengthReturns the length of str. The length of a C string is determined by the terminating null-character: A C string is as ... 阅读全文

posted @ 2012-04-24 23:09 D_D_U 阅读(273) 评论(0) 推荐(0) 编辑

atoi

摘要: function atoi <cstdlib> int atoi ( const char * str );Convert string to integerParses the C string str interpreting its content as an integral number, which is returned as an int value. The functi... 阅读全文

posted @ 2012-04-24 22:40 D_D_U 阅读(224) 评论(0) 推荐(0) 编辑

strncpy

摘要: char * strncpy ( char * destination, const char * source, size_t num );Copy characters from stringCopies the first num characters of source to destination. If the end of the source C string (which is ... 阅读全文

posted @ 2012-04-24 22:26 D_D_U 阅读(289) 评论(0) 推荐(0) 编辑

memset

摘要: function memset <cstring> void * memset ( void * ptr, int value, size_t num );Fill block of memorySets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted... 阅读全文

posted @ 2012-04-24 22:18 D_D_U 阅读(302) 评论(0) 推荐(0) 编辑

Arguments to main

摘要: Arguments to main For those writing programs which will run in a hosted environment, arguments to main provide a useful opportunity to give parameters to programs. Typically, this facility is used to... 阅读全文

posted @ 2012-04-24 21:47 D_D_U 阅读(250) 评论(0) 推荐(0) 编辑

argc and argv

摘要: argc and argv So far, all the programs we have written can be run with a single command. For example, if we compile an executable called myprog, we can run it from within the same directory with the ... 阅读全文

posted @ 2012-04-24 21:27 D_D_U 阅读(253) 评论(0) 推荐(0) 编辑

2012年4月17日

umask 详解

摘要: The umask The umask (UNIX shorthand for "user file-creation mode mask") is a four-digit octal number that UNIX uses to determine the file permission for newly created files. Every process has its own... 阅读全文

posted @ 2012-04-17 21:52 D_D_U 阅读(1828) 评论(0) 推荐(0) 编辑

狐狸和兔子

摘要: 有一个禅宗的故事这样说,一位禅师与弟子外出,看到狐狸在追兔子。“依据古代的传说,大部分清醒的兔子可以逃掉狐狸,这一只也可以。”师父说。“不可能!”弟子回答,“狐狸跑得比兔子快!”“但兔子将可避开狐狸!”师父仍然坚持已见。“师父,您为什么如此肯定呢?”“因为,狐狸是在追它的晚餐,免子是在逃命!”师父说。可叹息的是,大部分人过日子都像狐狸追兔子,以致到了中年,筋疲力尽就放弃自己的晚餐,纵使有些人追到了晚餐,也会觉得花那么大的代价, 才追到一只兔子感到懊丧。修行者的态度应该不是狐狸追兔子,而是兔子逃命,只有投入全副身心,向前奔驰飞跃,否则一个不留神,就会丧于狐口了。在生命的“点”和“点”间,快如迅雷 阅读全文

posted @ 2012-04-17 10:03 D_D_U 阅读(408) 评论(0) 推荐(2) 编辑

导航