随笔分类 - 日常练手
摘要:#include typedef union{ unsigned short value; unsigned char byte[2]; }CodeOrderUnion; void test_endian() { CodeOrderUnion order; order.value = 0x0102; if(order.byte[0] == 0x01 ...
阅读全文
摘要:void SafeStrAppend(char buf[], const uint32_t maxBufSize, uint32_t &offset, const char *format, ...) { if (offset < maxBufSize) { va_list ap; va_start(ap, format); off...
阅读全文
摘要:#include void rdump(int arr[],int len) { int i = 0; for(i=len-1;i >= 0; --i) { printf("%d",arr[i]); } printf("\n"); } void trailingZeroes(int n) { int arr[10000] = ...
阅读全文
摘要:#include #include #include #include #define NUM_CNT 10000000 #define FILE_NAME "num.txt" void genNumber() { int i = 0; int *arr = (int*)malloc(sizeof(int) * NUM_CNT); for(;i < NUM_C...
阅读全文
摘要:说明:在调用该函数前要先调用WSAStartup初始化Winsock
阅读全文
摘要:用以上语句导出的sql文件中,每条数据都按照一个INSERT语句来保存,方便用版本比较工具按行比较数据差异 例如
阅读全文
摘要:#include #include #include #define MAX_SIZE 20000 #define PARENT(i) (i/2) #define RIGHT(i) (i*2 + 1) #define LEFT(i) (i*2) #define EXCHANGE(a,b,t) do{t=a;a=b;b=t;}while(0) // 生成不重复的随机数序列写入文件 voi...
阅读全文
摘要:#include #include #include #define MAX_SIZE 20000 // 生成不重复的随机数序列写入文件 void gen_test_data(uint32_t cnt) { if( cnt >= MAX_SIZE){printf("cnt too largr\n");return;} uint32_t i = 0; char buf...
阅读全文
摘要:1 //字符串拷贝,排除指定字符 2 char *strcpy_exclude_char(char *dst, const int dst_len, const char *src, const char *exclude_list) 3 { 4 int i = 0, j = 0, flag = 0; 5 const char *p = NULL; 6 if ...
阅读全文
摘要:1 #include 2 int str_to_int(const char *str,int *num); 3 void int_to_str(char str[],const int strLen,const int num); 4 5 int main(int argc,char *argv[]) 6 { 7 char str[16]; 8 int ret...
阅读全文