随笔分类 -  C and C ++

[C puzzle book] Preprocessor for C
摘要:#include <stdio.h>#define FUDGE(k) k+3.14159#define PR(a) printf("a= %d\t",(int)(a))#define PRINT(a) PR(a); putchar('\n')#define PRINT2(a,b) PR(a); PRINT(b)#define PRINT3(a,b,c) PR(a); PRINT2(b,c)#define MAX(a,b) (a<b?b:a)int main(void){ { int x=2; PRINT(x*FUDGE(2)); } { . 阅读全文
posted @ 2012-08-10 13:49 abacuspix 阅读(220) 评论(0) 推荐(0)
[C puzzle book] Preprocessor
摘要:#include <stdio.h>#define FUDGE(k) k+3.14159#define PR(a) printf("a= %d\t",(int)(a))#define PRINT(a) PR(a); putchar('\n')#define PRINT2(a,b) PR(a); PRINT(b)#define PRINT3(a,b,c) PR(a); PRINT2(b,c)#define MAX(a,b) (a<b?b:a)int main(void){ { int x=2; PRINT(x*FUDGE(2)); } { . 阅读全文
posted @ 2012-08-10 13:46 abacuspix 阅读(232) 评论(0) 推荐(0)
[C puzzle book] Structure
摘要:#include <stdio.h>#define PR(format,value) printf(#value"= %"#format"\t",(value))#define NL putchar('\n')#define PRINT1(f,x1) PR(f,x1), NL#define PRINT2(f,x1,x2) PR(f,x1), PRINT1(f,x2)#define PRINT3(f,x1,x2,x3) PR(f,x1), PRINT2(f,x2,x3)#define PRINT4(f,x1,x2,x3,x4) 阅读全文
posted @ 2012-08-10 13:43 abacuspix 阅读(422) 评论(0) 推荐(0)
[C puzzle book] Pointers and Arrays
摘要:#include <stdio.h>#define PR(format,value) printf(#value"= %"#format"\t",(value))#define NL putchar('\n')#define PRINT1(f,x1) PR(f,x1), NL#define PRINT2(f,x1,x2) PR(f,x1), PRINT1(f,x2)#define PRINT3(f,x1,x2,x3) PR(f,x1), PRINT2(f,x2,x3)#define PRINT4(f,x1,x2,x3,x4) 阅读全文
posted @ 2012-08-10 13:35 abacuspix 阅读(236) 评论(0) 推荐(0)
[Zebos Learning] RIP
摘要:打算学学Zebos的实现方式 先从简单的RIP 入手吧Junos:9.4R4.5 Vs Zebra简单构建了一套环境 R1---------------Zebos---------------R2代码结构如下ripdThis directory contains all the code for RIP supporting IPv4.Descriptionripd.h ripd.c Functions to initiate, stop, and destroy ripd instancesrip_api.h rip_api.c ... 阅读全文
posted @ 2012-08-09 15:18 abacuspix 阅读(871) 评论(1) 推荐(0)
[C puzzle book] Storage Class
摘要://sc_4.c included filestatic int i=10;int next(){ return(i+=1);}int last(){ return (i-=1);}int new(i)int i;{ static int j=5; return (i=j+=i);}extern int i;reset(){ return (i);}#include <stdio.h>#define PR(format,value) printf(#value"= %"#format"\t",(value))#define NL putcha 阅读全文
posted @ 2012-08-09 13:14 abacuspix 阅读(207) 评论(0) 推荐(0)
[C puzzle book] Programming styles
摘要:/* Programming Style 1: Choose the Right Condition *Improve the following program fragments through reorganization */while(A) { if(B) continue; C;}do { if(!A) continue; else B; C; } while(A);if(A) if(B) if(C) D; else; else;else; if(B) if(C) E; el... 阅读全文
posted @ 2012-08-09 13:07 abacuspix 阅读(194) 评论(0) 推荐(0)
[C puzzle book] Control Flow
摘要:#include <stdio.h>#define PR(format,value) printf(#value"= %"#format"\t",(value))#define NL putchar('\n')#define PRINT1(f,x1) PR(f,x1), NL#define PRINT2(f,x1,x2) PR(f,x1), PRINT1(f,x2)#define PRINT3(f,x1,x2,x3) PR(f,x1), PRINT2(f,x2,x3)#define PRINT4(f,x1,x2,x3,x4) 阅读全文
posted @ 2012-08-09 13:01 abacuspix 阅读(323) 评论(0) 推荐(0)
[C puzzle book] types
摘要:#include <stdio.h>#define PRINT(format,x) printf("x = %"#format"\n",(x))//how to add the # ????int integer = 5;char character = '5';char *string = "5";int main(void){ PRINT(d,string); PRINT(d,character); PRINT(d,integer); PRINT(d,string); PRINT(c,character 阅读全文
posted @ 2012-08-09 12:54 abacuspix 阅读(219) 评论(0) 推荐(0)
A function for new storage space of string
摘要:/*Write a new function to allocate a consitentspace for string*/#define NULL 0#define NEWSIZE 1000char newbuf[NEWSIZE];char *newp= newbuf;char *New(int n){ if(newp+n<=newbuf+NEWSIZE) { newp=newp+n; return(newp-n); } else return(NULL);} 阅读全文
posted @ 2012-08-08 22:14 abacuspix 阅读(148) 评论(0) 推荐(0)
【书评】OSPF Anatomy of an Internet Routing Protocol
摘要:最近找到一本书 发现是 Moy大神写的 有些老和原来的netwroking 方面的书有些不一样的东西 还是值得一读。比如 OSPF的 八卦, 从一个设计者的角度阐述一个协议,能学到些协议以外的东西。还有本书姐妹篇OSPF Complete ImplementationPublished by arrangement with Addison Wesley也一并下了 可惜不是E文版 从头到尾介绍了 C++下的OSPF实现精读一下应该还是会有所得的。 阅读全文
posted @ 2012-08-08 16:01 abacuspix 阅读(303) 评论(0) 推荐(0)
【转】闲聊Kernel engineer的境界(全)
摘要:我来瞎谈一下Kernel Engineer的几个境界。瞎谈呀,弟兄们别当真。闲聊Kernel engineer的境界境界(一):1. 喜欢OS。别的啥也看不上。2. 读kernel代码,每天特来劲。饭桌上特牛逼:-)3. 觉得自己啥也不懂,看了就忘,特沮丧。4. 玩板子,特来劲,饭桌上具牛逼。闲聊Kernel engineer的境界(二) 1. 开始谁也看不起,觉得做网络的其实就是大傻。 做Driver的其实就是脑残。 (2)喜欢做芯片的,特别是做CPU的。会开始补充体系结构的知识。 (3)发现bus很重要,但大多数人不懂。(4)慢慢往硬件上靠。闲聊Kernel engineer的境界(三)( 阅读全文
posted @ 2012-07-23 22:48 abacuspix 阅读(205) 评论(0) 推荐(0)