![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c
wegatron
这个作者很懒,什么都没留下…
展开
-
c/c++ #pragma
一、VC中提供了#pragma pack(n)来设定变量以n字节对齐方式。n字节对齐就是说变量存放的起始地址的偏移量有两种情况:第一、如果n大于等于该变量所占用的字节数,那么偏移量必须满足默认的对齐方式,第二、如果n小于该变量的类型所占用的字节数,那么偏移量为n的倍数,不用满足默认的对齐方式。结构的总大小也有个约束条件,分下面两种情况:如果n大于所有成员变量类型所占用的字节原创 2012-06-06 17:11:18 · 279 阅读 · 0 评论 -
自己在Linux上写的一个线程池的程序
这个线程池和通常用的有些不一样,通常,都应该具有任务队列。主线程把任务放入任务队列就完了,这个线程池的话,没有任务队列,有就是说,当最大的线程数量在工作的时候,主线程会挂起。#include #include #include #include #define MAX_THREAD 10#define MIN_THREAD 1typedef void (*threadJobFu原创 2012-09-26 15:18:05 · 371 阅读 · 0 评论 -
pthread_cond_wait()用法分析
条件变量 条件变量是利用线程间共享的全局变量进行同步的一种机制,主要包括两个动作:一个线程等待"条件变量的条件成立"而挂起;另一个线程使"条件成立"(给出条件成立信号)。为了防止竞争,条件变量的使用总是和一个互斥锁结合在一起。 1. 创建和注销 条件变量和互斥锁一样,都有静态动态两种创建方式,静态方式使用PTHREAD_CO转载 2012-09-24 17:11:14 · 397 阅读 · 0 评论 -
C input and output 摘录《The C Programming Language》
/* int ferror ( FILE * stream ); Checks if the error indicator associated with stream is set, returning a value different from zero if it is. 当文件以r打开,或者磁盘满时会返回非0.*/#include int main (){ FIL原创 2012-09-13 20:01:56 · 534 阅读 · 0 评论 -
Variable-length Argument Lists
C 语言的可变参数函数样例,摘自《The c programming language》#include void minprintf(char *fmt, ...){ va_list ap; /*points to each unnamed arg in turn */ char *p, *sval; double dval; va_start(ap,fmt); /* ma原创 2012-09-11 19:47:51 · 267 阅读 · 0 评论 -
《The C programming language》摘录
/* This loop prints n elements of an array, 10 per line, with each column separated by one blank. */for (i = 0; i < n; i++) printf("%6d%c", a[i], (1%10==9 || i==n-1) ? '\n' : ' ');/* This migh原创 2012-08-23 10:58:58 · 284 阅读 · 0 评论 -
自己写的线程池(可供他人调用)
/* thread_pool.h */#ifndef THREAD_POOL#define THREAD_POOL#define MAX_THREAD 10#define MIN_THREAD 1typedef void (*threadJobFunc)(void *jobdata);typedef struct _threadPool threadPool;struct _thr原创 2012-09-26 17:06:23 · 405 阅读 · 0 评论 -
VS CRT 的解释
CRT 全称:Visual C++ C RunTime Lib 就是C运行时库。注: 以下内容部分引自CSND中相关讨论的帖子,并结合自己的理解整理而成。仅供参考。1)运行时库就是 C run-time library,是 C 而非 C++ 语言世界的概念:取这个名字就是因为你的 C 程序运行时需要这些库中的函数.2)C 语言是所谓的“小内核”语言,就其语言本身来说很小(不多的关键字转载 2012-08-07 11:46:12 · 491 阅读 · 0 评论 -
define 的用法小结——摘自《THE PROGRAMMING LANGUAGE C》
1.make sure that the contents of a file are included only once.#if !defined(HDR)#define HDR/* contents of hdr.h go here */#endifalso we can write this way#ifndef HDR#define HDR/* content原创 2012-06-21 19:04:01 · 296 阅读 · 0 评论 -
#define do{} while(0) 用法妙用
总地来说是实现复杂的定义,通用性强,任何情况下都适用#define MACRO_NAME(para) do{macro content}while(0)的格式,总结了以下几个原因:1,空的宏定义避免warning: #define foo() do{}while(0) 2,存在一个独立的block,可以用来进行变量定义,进行比较复杂的实现。3,如果出现在判转载 2012-06-21 17:01:17 · 476 阅读 · 0 评论 -
c/c++学习记录一
不同的struct之间可以根据其内存的存放规则进行强制类型转换。实例1:#include #include struct addr{ int ip; char host_name[100];};struct addr_in{ int ip; char host_name[100]; int other;};int main()原创 2012-06-20 18:29:56 · 236 阅读 · 0 评论 -
linux 下用c获取网页
#include #include #include #include #include #include #include int main(int argc,char **argv){ if (argc<2){ printf( "Please input the hostName. Example:\n %s www.baidu.com\n ",argv[0]);原创 2012-07-05 11:08:26 · 366 阅读 · 0 评论 -
标准c语言笔记.pdf
结合c/c++开发经历,以及《THE C PROGRAMMING LANGUAGE》和 《C Traps and Pitfails》的阅读笔记。地址http://download.csdn.net/download/wegatron/5068641原创 2013-02-17 21:04:17 · 239 阅读 · 0 评论