上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 21 下一页
摘要: 回调函数的一个典型应用就是实现类似C++的泛型算法(Generics Algorithm)。下面实现的max函数可以在任意一组对象中找出最大值,可以是一组int、一组char或者一组结构体,但是实现者并不知道怎样去比较两个对象的大小,调用者需要提供一个做比较操作的回调函数。 1 /* generics.h */ 2 #ifndef GENERICS_H 3 #define GENERICS_H 4 5 typedef int (*cmp_t)(void *, void *); 6 extern void *max(void *data[], int num, cmp_t cmp); 7 ... 阅读全文
posted @ 2013-06-19 18:08 net小伙 阅读(671) 评论(0) 推荐(0) 编辑
摘要: 编一个函数,输入一个字符串,要求做一个新字符串,把其中所有的一个或多个连续的空白字符都压缩为一个空格。这里所说的空白包括空格、'\t'、'\n'、'\r'。例如原来的字符串是:This Content hoho is ok ok? file systemuttered words ok ok ?end.压缩了空白之后就是:This Content hoho is ok ok? file system uttered words ok ok ? end. 1 #include <stdio.h> 2 int judge_char(cha 阅读全文
posted @ 2013-06-18 02:31 net小伙 阅读(803) 评论(0) 推荐(0) 编辑
摘要: const限定符和指针结合起来常见的情况有以下几种。const int *a;int const *a;这两种写法是一样的,a是一个指向const int型的指针,a所指向的内存单元不可改写,所以(*a)++是不允许的,但a可以改写,所以a++是允许的。int * const a;a是一个指向int型的const指针,*a是可以改写的,但a不允许改写。int const * const a;a是一个指向const int型的const指针,因此*a和a都不允许改写。指向非const变量的指针或者非const变量的地址可以传给指向const变量的指针,编译器可以做隐式类型转换,例如:char c 阅读全文
posted @ 2013-06-17 01:48 net小伙 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 通过创建命名管道实现任何一个进程的通信:mkfifo_read.c 1 #include<stdio.h> 2 #include<string.h> 3 #include<sys/types.h> 4 #include<sys/stat.h> 5 6 #include<fcntl.h> 7 #include<stdlib.h> 8 9 #define FIFO "text"10 11 int main(int argc, char *argv[])12 {13 int fd;14 int mkfi;15 阅读全文
posted @ 2013-06-10 15:33 net小伙 阅读(257) 评论(0) 推荐(0) 编辑
摘要: asctime(将时间和日期以字符串格式表示) 相关函数 time,ctime,gmtime,localtime 表头文件 #include<time.h> 定义函数 char * asctime(const struct tm * timeptr); 函数说明 asctime()将参数timeptr所指的tm结构中的信息转换成真实世界所使用的时间日期表示方法,然后将结果以字符串形态返回。此函数已经由时区转换成当地时间,字符串格式为:“Wed Jun 30 21:49:08 1993\n” 返回值 若再调用相关的时间日期函数,此字符串可能会被破坏。此函数与ctime不同处在于传入的 阅读全文
posted @ 2013-06-08 10:28 net小伙 阅读(332) 评论(0) 推荐(0) 编辑
摘要: linux中除了常见的读(r)、写(w)、执行(x)权限以外,还有3个特殊的权限,分别是setuid、setgid和stick bit1、setuid、setgid先看个实例,查看你的/usr/bin/passwd 与/etc/passwd文件的权限[root@MyLinux ~]# ls -l /usr/bin/passwd /etc/passwd-rw-r--r--1 root root 154908-1913:54/etc/passwd-rwsr-xr-x 1 root root 229842007-01-07/usr/bin/passwd众所周知,/etc/passwd文件存放的各个. 阅读全文
posted @ 2013-06-07 11:20 net小伙 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 5 typedef struct node 6 { 7 int item; 8 struct node *next; 9 }node; 10 11 typedef struct queue 12 { 13 node *front; 14 node *rear; 15 }queue; 16 17 char getfirst() 18 { 19 char value; 20 value = getc... 阅读全文
posted @ 2013-06-06 10:41 net小伙 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 1.下载tftp服务器、客户端tftp和守护进程xinetd三个包yum install xinetd tftp tftp-server //xinetd.i386 2:2.3.14-21.fc10//tftp-0.49-1.fc10.i386.rpm //tftp-server-0.49-1.fc10.i386.rpm 2.配置vi /etc/xinetd.d/tftp 修改server_args = -s /tftpboot -c,这里的-c一定要加上,否则只能下载不能上传!!!service tftp{disable = nosocket_typ... 阅读全文
posted @ 2013-06-05 16:05 net小伙 阅读(1894) 评论(0) 推荐(0) 编辑
摘要: 1简介GCC 的意思也只是 GNU C Compiler 而已。经过了这么多年的发展,GCC 已经不仅仅能支持 C 语言;它现在还支持 Ada 语言、C++ 语言、Java 语言、Objective C 语言、Pascal 语言、COBOL语言,以及支持函数式编程和逻辑编程的 Mercury 语言,等等。而 GCC 也不再单只是 GNU C 语言编译器的意思了,而是变成了 GNU Compiler Collection 也即是 GNU 编译器家族的意思了。另一方面,说到 GCC 对于操作系统平台及硬件平台支持,概括起来就是一句话:无所不在。2简单编译示例程序如下://test.c#includ 阅读全文
posted @ 2013-06-04 21:06 net小伙 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 一:点击安装VMware Tools;二:此时系统桌面上会出现图标VMware Tools;这里面文件位于/media 文件夹下;里面有两个文件我们用第二个;三:把第二个文件用命令:tar xvfz /media/VMware\ Tools/VMwareTools-6.0.2-59824.tar.gz -C /opt 把文件加压到/opt文件夹中;四:用命令:cd /opt/vmware-tools-distrib/ 转到此目录下;五:执行命令: ./vmware-install.p1 安装工具;然后就是一路enter键,需要yes的输入yes ,需要no的输入no;即可;如果比较幸运,那.. 阅读全文
posted @ 2013-06-02 12:01 net小伙 阅读(624) 评论(0) 推荐(1) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 21 下一页