摘要:共享全局变量实例:#include #include #include #include int key=100;void *helloworld_one(char *argc){ printf("the message is %s\n",argc); key=10; printf...
阅读全文
摘要:#include #include #include #include void cleanup(){ printf("cleanup\n");}void *test_cancel(void){ pthread_cleanup_push(cleanup,NULL); printf(...
阅读全文
摘要:#include #include #include #include struct message{ int i; int j;};void *hello(struct message *str){ printf("child, the tid=%lu, pid=%d\n",pt...
阅读全文
摘要:此实例是一个简单的使用消息队列进行实时聊天的本机通信程序,,发送端每发送一个消息,会立即被接收读取,在没有消息在消息队列中时,将处于阻塞状态。终端1运行接收端#include #include #include #include #include #include #include struct m...
阅读全文
摘要:key_t ftok(const char *_pathname, int _proj_id)key值的第31~24位为ftok()第二个参数的低8位;key值的第23~16位为ftok()第一个参数文件属性的st_dev成员的低8位;key值的第15~0位为ftok()第一个参数文件属性的st_i...
阅读全文
摘要:#include #include #include #include #include #include #define BUFFER_SIZE 1024int main(int argc, char *argv[]){ int fd; char buffer[BUFFER_SIZE]...
阅读全文
摘要:毫无疑问,不管是32位,还是64位处理器,所有进程(执行的程序)都必须占用一定数量的内存,它或是用来存放从磁盘载入的程序代码,或是存放取自用户输入的数据等等。不过进程对这些内存的管理方式因内存用途不一而不尽相同,有些内存是事先静态分配和统一回收的,而有些却是按需要动态分配和回收的。对任何一个普通进程...
阅读全文
摘要:readdir()在多线程操作中不安全,Linux提供了readdir_r()实现多线程读取目录内容操作。#include #include #include int main(void){ DIR* dirp; struct dirent *dp1=malloc(sizeof(stru...
阅读全文
摘要:1.memmove函数原型:void *memmove(void *dest, const void *source, size_t count)返回值说明:返回指向dest的void *指针参数说明:dest,source分别为目标串和源串的首地址。count为要移动的字符的个数函数说明:memm...
阅读全文
摘要:1.提取字符串2.提取指定长度的字符串3.提取指定字符为止的字符串4.取仅包含指定字符集的字符串5.取到指定字符集为止的字符串#include int main(){ char str[512]={0}; sscanf("123456","%s",str); printf("str...
阅读全文
摘要:#include #include float get_cpu_clock_speed(){ FILE *fp; char buffer[1024]; size_t bytes_read; char *match; float clock_speed; fp=fo...
阅读全文
摘要:#include #include #include int main(){ srand(time(0)); char s[64]; int offset=0; int i; for(i=0;i<10;i++) { offset+=sprintf(s...
阅读全文
摘要:(1)打印字符char c;printf("%c",c);(2)打印整形int i;printf("%d",i); //有符号十进制数printf("%u",i); //无符号十进制数(3)打印浮点数float f;printf("%f",f);(4)打印指针int *p;pri...
阅读全文
摘要:#include #include #include int main(int argc,char **argv){ FILE *fp_src,*fp_des; char buf[128]; int num; if(argc!=3) { printf("t...
阅读全文
摘要:#include #include #include int main(int argc,char *argv[]){ int n=0; FILE *fp; if((fp=fopen(argv[1],"r"))==NULL) { perror("fopen");...
阅读全文
摘要:相关函数fork, execle, execlp, execv, execve, execvpWindows下头文件#include Linux下头文件#include 函数定义int execl(const char *path, const char *arg, ...);函数说明execl()...
阅读全文
摘要:#include void pr_stdio(const char *, FILE *);int main(){ FILE *fp; fputs("enter any character\n",stdout); if(getchar()==EOF) printf("getchar error");...
阅读全文