摘要:
带括号补齐 1 syntax on 2 filetype plugin on 3 let filetype_m='objc' 4 set nocompatible 5 set encoding=utf-8 6 set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 7 set history=400 8 set autoread 9 set nu10 set ai11 set cindent12 set cmdheight=213 set backspace=eol,start,indent14 set ignorecase smart 阅读全文
摘要:
/** *函数实现将网址进行如下操作 *www.google.com转成com.google.www 及mail.netease.com转成com.netease.mail * *不允许用STL,空间为0(1) * *C/C++ code * *void reverse(cha * ptr) *{ * * *} * ***/char* find_next_right_dot(char *str){ if(str == NULL) return NULL; char * src = str; //save the source string address whi... 阅读全文
摘要:
2分快速排序C代码: 1 typedef unsigned char BYTE; 2 3 void swap(BYTE *a, BYTE *b) 4 { 5 if(a != b) { 6 *a = *a ^ *b; 7 *b = *b ^ *a; 8 *a = *a ^ *b; 9 }10 }11 12 /***13 *2路划分快速排序14 *15 **/16 int partition(BYTE *array, int left, int right)17 {18 int i = left - 1, j = ri... 阅读全文
摘要:
在资源初始化的代码块中,除了用goto可以用作出错处理之外还可以使用do { } while(0)使用break就可以跳出来进行出错处理,缺点是少了标签的层次出错处理。C++实例代码:截自Mac OSX USB驱动 1 do { 2 if(!newDevice->init(deviceAddress, powerAvaliable, speed, maxPacketSize)) 3 break; 4 if(!newDevice->attach(this)) 5 break; 6 if(!newDevice->start(this)) { ... 阅读全文