05 2015 档案

CPP高级数组
摘要:1 /* CPP高级数组 */ 2 3 #include 4 #include 5 #include// C++标准库 6 #include// C++字符串 7 using std::array;// 静态数组 在栈上 8 using std::vector;// 动态数组 在... 阅读全文

posted @ 2015-05-31 22:25 Dragon-wuxl 阅读(180) 评论(0) 推荐(0)

CPP新类型数组
摘要:1 /* CPP新类型数组 */ 2 3 #include 4 #include 5 #include 6 #include 7 8 void main() 9 {10 double db[4] = {1.1,2.2,3.3,4.4};11 12 // std::array 数组的数... 阅读全文

posted @ 2015-05-31 17:13 Dragon-wuxl 阅读(472) 评论(0) 推荐(0)

通用函数可变参数模板
摘要:1 /* 通用函数可变参数模板 */ 2 3 #include 4 5 // 通用可变参数模板 处理不限定个数的参数 处理不同类型的参数 6 void showall()// 空函数,起到接口的作用 最后结束递归 7 { 8 9 }10 11 template12 13 // Args ... 阅读全文

posted @ 2015-05-31 16:31 Dragon-wuxl 阅读(109) 评论(0) 推荐(0)

可变参数高级模板
摘要:1 #include 2 #include 3 4 void showall(){};//预留一个 5 6 7 template 8 void show(T t, ...) 9 {10 std::cout 14 15 void showall(T t, Args...args)16... 阅读全文

posted @ 2015-05-31 16:04 Dragon-wuxl 阅读(115) 评论(0) 推荐(0)

函数模板与普通函数的选择问题
摘要:1 /* 函数模板与普通函数的选择问题 */ 2 3 #include 4 5 // 函数模板可以对类型进行优化重载 根据类型会覆盖 6 // 如果仍然需要使用模板函数需要实例化 7 8 9 template10 11 T add(T a,T b)12 {13 std::cout... 阅读全文

posted @ 2015-05-31 15:52 Dragon-wuxl 阅读(124) 评论(0) 推荐(0)

CPP类型转换
摘要:1 /* CPP类型转换 */ 2 3 #include 4 #include 5 6 void main() 7 { 8 double db = 10.9 9 float fl = db;// 默认数据类型转换10 std::cin.get();11 }12 13 /... 阅读全文

posted @ 2015-05-31 15:34 Dragon-wuxl 阅读(490) 评论(0) 推荐(0)

函数模板的覆盖
摘要:1 /* 函数模板的覆盖 */ 2 3 #include 4 5 // 函数模板可以实现通用,可以根据自有的数据类型进行优化 6 7 8 template 9 10 void swap(T &a,T &b)11 {12 std::cout 54 void swap(T &a,T &... 阅读全文

posted @ 2015-05-31 14:42 Dragon-wuxl 阅读(198) 评论(0) 推荐(0)

函数包装器管理外部函数
摘要:1 /* 函数包装器管理外部函数 */ 2 3 // 函数包装器,用于管理内嵌函数,外部函数调用 4 template 5 T run(T v1,T v2,F f) 6 { 7 return f(v1,v2);// 函数传入参数 8 } 9 10 int cheng(int a,int... 阅读全文

posted @ 2015-05-31 10:14 Dragon-wuxl 阅读(117) 评论(0) 推荐(0)

函数包装器
摘要:1 /* 函数包装器 */ 2 3 4 // 函数包装器: 5 /* 6 第一,设计通用执行的接口,设计关卡,计数 7 第二,函数包装器依赖函数模板,实现通用泛型 8 第三,函数代码可以内嵌在另外一个函数,实现函数怀孕 9 */1... 阅读全文

posted @ 2015-05-31 10:04 Dragon-wuxl 阅读(219) 评论(0) 推荐(0)

inline(内联函数)
摘要:1 /* inline 函数(内联函数) */ 2 3 4 #include 5 6 #define GETX3(N) N*N*N// 替换 7 8 // inline 只是对于编译器的建议 9 // 一般情况下我们对内联函数做如下的限制:10 /*11 (1) 不... 阅读全文

posted @ 2015-05-30 21:09 Dragon-wuxl 阅读(177) 评论(0) 推荐(0)

宽字符
摘要:1 #include 2 #include 3 #include 4 5 int main() 6 { 7 setlocale(LC_ALL, "chs");// 设置本地化 8 wchar_t *p1 = L"123456"; 9 std::wcout << p1 <<... 阅读全文

posted @ 2015-05-30 20:51 Dragon-wuxl 阅读(107) 评论(0) 推荐(0)

引用高级
摘要:1 /* 引用高级 */ 2 3 /* 引用一维数组 */ 4 #include 5 #include 6 7 void main() 8 { 9 int a[10] = {1,2,3,4,5,6,7,8,9,10}; 10 int(& ra)[10](a);... 阅读全文

posted @ 2015-05-28 21:39 Dragon-wuxl 阅读(242) 评论(0) 推荐(0)

ccpp的enum
摘要:1 /* enum */ 2 3 // c 语言 4 5 #include 6 7 enum color{red=11,yellow,green,white}; 8 9 void main()10 {11 enum color c1;12 cl = red;// 不注重数... 阅读全文

posted @ 2015-05-28 09:29 Dragon-wuxl 阅读(145) 评论(0) 推荐(0)

bool类型
摘要:1 /* bool */ 2 3 #include 4 5 int main() 6 { 7 bool b1 = 1 && 1 || 2 || -1 && 0; 8 std::cout << typeid(b1).name() << std::endl; 9 std::... 阅读全文

posted @ 2015-05-28 09:09 Dragon-wuxl 阅读(135) 评论(0) 推荐(0)

auto自动类型
摘要:1 /* auto自动类型 */ 2 3 #include 4 5 int main() 6 { 7 double db = 10.9; 8 double *pdb = &db; 9 auto num = pdb;// 通用传入接口10 std::cout <<... 阅读全文

posted @ 2015-05-28 08:59 Dragon-wuxl 阅读(168) 评论(0) 推荐(0)

new和delete
摘要:1 /*new delete*/ 2 3 #include 4 #include 5 #include 6 7 void main() 8 { 9 int num = 10;// 栈上 10 int *p = new int;// 堆上 11 *p =... 阅读全文

posted @ 2015-05-27 16:17 Dragon-wuxl 阅读(121) 评论(0) 推荐(0)

const 说明
摘要:1 /* const 说明 */ 2 3 void main() 4 { 5 int data = 100; 6 const int num = 100;//c++保证常量绝对不被修改 7 std::cout (&num);// 强制去掉const属性 9 *p ... 阅读全文

posted @ 2015-05-27 14:21 Dragon-wuxl 阅读(85) 评论(0) 推荐(0)

constcpp
摘要:1 /*constCCPP*/ 2 3 // c语言 4 void main() 5 { 6 const int num =5; 7 int a[num];// 不可以 8 int *p = &num; 9 *p = 3;// c语言是弱类型语言... 阅读全文

posted @ 2015-05-27 11:14 Dragon-wuxl 阅读(89) 评论(0) 推荐(0)

左值与右值引用
摘要:1 /*左值与右值*/ 2 3 #include 4 #include 5 6 // 左值就是可以放在赋值号左边被赋值的值,必须在内存有实体 7 // 右值就是可以放在赋值号右边取出值赋给其他变量的值 8 // 右值可以在内存也可以在寄存器 9 10 void main()... 阅读全文

posted @ 2015-05-27 09:34 Dragon-wuxl 阅读(93) 评论(0) 推荐(0)

泛型auto
摘要:1 /*auto*/ 2 3 #include 4 5 void main() 6 { 7 auto num = 10.9; // 自动变量 自动匹配类型 8 auto numA = 10; 9 std::cout << num << numA << std::endl... 阅读全文

posted @ 2015-05-26 10:08 Dragon-wuxl 阅读(147) 评论(0) 推荐(0)

函数重载与函数默认参数
摘要:1 /*函数重载的原理*/ 2 3 // c中 4 5 // 参数的个数参数的类型不同 顺序不同 与返回值无关 6 void go(int a) 7 { 8 std::cout << a; 9 }10 11 void go(double a)12 {13 std::cout <... 阅读全文

posted @ 2015-05-26 09:39 Dragon-wuxl 阅读(144) 评论(0) 推荐(0)

命名空间详解
摘要:1 /*命名空间详解*/ 2 3 namespace runrunrunrun 4 { 5 int a(10); 6 char *str("gogogo"); 7 namespace run // 命名空间的嵌套 8 { 9 in... 阅读全文

posted @ 2015-05-25 22:32 Dragon-wuxl 阅读(109) 评论(0) 推荐(0)

C与CPP不同以及命名空间简介
摘要:1 /*C,Cpp不同*/ 2 3 #include 4 void main() 5 { 6 int *p1 = null; 7 double *p2 = null; 8 p1=p2; // c语言类型检查不明确 9 }10 // c中可以编译通过 c++中不行 C... 阅读全文

posted @ 2015-05-25 21:32 Dragon-wuxl 阅读(296) 评论(0) 推荐(0)

临时文件的创建以及自动创建临时文件名和添加临时文件扩展名
摘要:临时文件的创建: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 // tmpfile产生临时文件,关闭文件或者程序关闭,就会自动删除 6 // 创建临时文件 7 void main() 8 { 9 FILE *pt... 阅读全文

posted @ 2015-05-25 16:33 Dragon-wuxl 阅读(1145) 评论(2) 推荐(0)

遍历文件夹下所有文件
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 /* 6 dir遍历当前目录下所有文件以及文件夹 输出日期与时间 7 附加/b 以后,就可以仅仅显示文件名或者文件夹名 8 /a:-d 排除目录 9 ... 阅读全文

posted @ 2015-05-25 15:17 Dragon-wuxl 阅读(389) 评论(0) 推荐(0)

文件中检索字符串
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 /* 6 find [/v] [/c] [/n] [/i] ["string"[[drive:] [path] filename[...]] 7 /v 显示... 阅读全文

posted @ 2015-05-25 14:42 Dragon-wuxl 阅读(143) 评论(0) 推荐(0)

链表的快速排序
摘要:1 void quicksort(node* pbegin, node *pback)// 链表的快排 2 { 3 if (pbegin != pback) 4 { 5 node *pfen = fen(pbegin, pback);//取中间点 6 ... 阅读全文

posted @ 2015-05-23 10:06 Dragon-wuxl 阅读(166) 评论(0) 推荐(0)

链表的冒泡排序
摘要:1 void bubblesort(node *phead)// 链表的冒泡排序 2 { 3 // 数组可以随机访问任何一个元素,链表找到N个元素,先遍历N-1 4 for (node *p1 = phead; p1!=NULL;p1=p1->pNext) 5 { 6 ... 阅读全文

posted @ 2015-05-23 08:52 Dragon-wuxl 阅读(246) 评论(0) 推荐(0)

链表的增删改查
摘要:头文件:linklist.h 1 #include 2 #include 3 4 struct LinkNode 5 { 6 int data;// 数据域 7 struct LinkNode *pNext;// 指针域 8 }; 9 10 typedef struct LinkN... 阅读全文

posted @ 2015-05-22 21:03 Dragon-wuxl 阅读(195) 评论(0) 推荐(0)

简单链表
摘要:1 #include 2 #include 3 4 struct MyStruct 5 { 6 int data;//数据域 7 struct MyStruct *pNext;//指针域 8 }; 9 10 // 递归实现链表数据打印11 void show(struct M... 阅读全文

posted @ 2015-05-21 12:59 Dragon-wuxl 阅读(110) 评论(0) 推荐(0)

结构体与共用体大小字节对齐
摘要:1 #include 2 //必须整除最宽基本成员 3 //成员地址-首地址必须可以整除当前成员大小,结构体独有 4 //不足的填充 5 6 struct MyStruct 7 { 8 char str[23];//24 9 short db;// 设置,当前最宽 两者取最短... 阅读全文

posted @ 2015-05-19 20:48 Dragon-wuxl 阅读(194) 评论(0) 推荐(0)

共用体变量初始化方式
摘要:1 #include 2 #include 3 4 /* 5 使用共用体变量的目的是希望通过统一内存段存放几种不同类型的数据。 6 但是要注意,每一瞬间只能存放一种,而不是存放集中。并且,如果对新的成员变量的话, 7 原来的成员变量的值就被覆盖了。 8 9 不能... 阅读全文

posted @ 2015-05-19 12:15 Dragon-wuxl 阅读(910) 评论(0) 推荐(0)

共用体定义
摘要:1 #include 2 #include 3 4 /* 5 共同体的定义类似结构体,不过共同体的所有成员都在同一段内存中存放, 6 起始地址一样,并且同一时刻只能使用其中的一个成员变量 7 */ 8 union MyUnion 9 {10 int num;11 ... 阅读全文

posted @ 2015-05-19 10:44 Dragon-wuxl 阅读(267) 评论(1) 推荐(0)

位域编程实战
摘要:1 #include 2 #include 3 4 struct bits 5 { 6 unsigned char ch1 : 1; 7 unsigned char ch2 : 1; 8 unsigned char ch3 : 1; 9 unsigned char... 阅读全文

posted @ 2015-05-19 10:19 Dragon-wuxl 阅读(154) 评论(0) 推荐(0)

位域的概念
摘要:1 #include 2 #include 3 4 struct MyStruct 5 { 6 //位域,限定数据的位数,节约内存 7 unsigned int a : 5; 8 unsigned int b : 5; 9 unsigned in... 阅读全文

posted @ 2015-05-19 10:10 Dragon-wuxl 阅读(2873) 评论(0) 推荐(0)

结构体与指针
摘要:1 #include 2 #include 3 #include 4 5 struct data 6 { 7 int num; 8 }; 9 void main()10 {11 struct data(*p)[10] = malloc(sizeof(struct data) * ... 阅读全文

posted @ 2015-05-18 22:24 Dragon-wuxl 阅读(126) 评论(0) 推荐(0)

结构体和结构体副本机制
摘要:1 #include 2 #include 3 4 struct MyStruct 5 { 6 int a[10]; 7 int length; 8 }; 9 10 void change(struct MyStruct s1)//副本机制,对于结构体生效(结... 阅读全文

posted @ 2015-05-18 21:28 Dragon-wuxl 阅读(311) 评论(0) 推荐(0)

结构体大小
摘要:1 #include 2 #include 3 4 /* 5 6 结构体大小大于等于所有成员的大小之和 7 char int double float //基本类型 double最宽基本成员 8 结构体的大小必须可以整除最宽基本成员 9 结构体成员的地址... 阅读全文

posted @ 2015-05-18 13:10 Dragon-wuxl 阅读(128) 评论(0) 推荐(0)

结构体动态数组,结构体与指针
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 7 8 struct csdn 9 {10 int id;11 int num;12 };13 14 void mai... 阅读全文

posted @ 2015-05-18 10:15 Dragon-wuxl 阅读(417) 评论(0) 推荐(0)

结构体数组
摘要:1 #include 2 #include 3 4 // 结构体数组的定义 5 6 struct // 匿名结构体 主要作用是锁定变量的个数 7 { 8 int num; 9 double db;10 }*p,x[10],z; // p是指针 x是数组 z 是变量11 12... 阅读全文

posted @ 2015-05-17 22:31 Dragon-wuxl 阅读(189) 评论(0) 推荐(0)

结构体的嵌套
摘要:1 #include 2 #include 3 4 //链表嵌套实现继承,描述复杂的事物属性,C数据结构都是结构体, 5 struct other 6 { 7 int canmove; 8 }; 9 10 struct animal11 {12 struct other o... 阅读全文

posted @ 2015-05-17 16:05 Dragon-wuxl 阅读(224) 评论(0) 推荐(0)

结构体的赋值
摘要:1 #include 2 #include 3 4 struct MyStruct 5 { 6 int a[5]; 7 char str[10]; 8 char *p; 9 };10 11 void main()12 {13 // 数组 变量没有深浅拷贝的差别 ... 阅读全文

posted @ 2015-05-17 15:31 Dragon-wuxl 阅读(120) 评论(0) 推荐(0)

结构体,深浅拷贝
摘要:1 #include 2 #include 3 4 struct MyStruct 5 { 6 char *p; 7 int num; 8 }; 9 10 //对于数据来说,深浅拷贝一样,对于指针,浅拷贝是拷贝地址,深拷贝拷贝内存内容11 void main()12 {13 ... 阅读全文

posted @ 2015-05-17 12:53 Dragon-wuxl 阅读(125) 评论(0) 推荐(0)

结构体的引用
摘要:1 #include 2 #include 3 4 struct MyStructA 5 { 6 //int num = 10;// C语言结构体内部变量不能有初始化 C++ 可以 7 int num; 8 char str[10]; 9 };10 11 struct M... 阅读全文

posted @ 2015-05-17 10:36 Dragon-wuxl 阅读(163) 评论(0) 推荐(0)

时间优先字符串压缩与解压缩
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 // 时间优先 8 char * timefastzip(char *str) 9 {10 int length = strlen(str);//获取长度11 ... 阅读全文

posted @ 2015-05-16 21:53 Dragon-wuxl 阅读(124) 评论(0) 推荐(0)

结构体,匿名结构体的变量多种初始化方式
摘要:1 #include 2 #include 3 4 struct MyStructA 5 { 6 int num; 7 char str[10]; 8 }s1={10,"123"}; // 第一种结构体初始化方式 注意初始化的顺序要一致 9 10 struct MyStruct... 阅读全文

posted @ 2015-05-16 15:49 Dragon-wuxl 阅读(544) 评论(0) 推荐(0)

结构体初识,结构体的定义,匿名结构体,结构体的嵌套
摘要:1 #include 2 #include 3 4 // 定义一个结构体 5 struct student 6 { 7 char name[20]; 8 int age; 9 long long telephone;10 double score;11 };12 ... 阅读全文

posted @ 2015-05-16 14:37 Dragon-wuxl 阅读(293) 评论(0) 推荐(0)

判断输入的字符串是否对称
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 int issymmetry(char *str)// 判读输入的字符串是否对称 6 { 7 int flag = 1; // 假定一开始0为不对称,1为对称 8 ... 阅读全文

posted @ 2015-05-16 09:27 Dragon-wuxl 阅读(288) 评论(0) 推荐(0)

删除字符串表达式空格以及对包含加减运算符字符串进行计算结果
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 // 指针法 6 void pointeatspace(char *str)// 对字符串做去除空格处理 7 { 8 char *p1 = str; ... 阅读全文

posted @ 2015-05-15 15:41 Dragon-wuxl 阅读(313) 评论(0) 推荐(0)

宽字符的学习以及手动实现相关函数 ------ wcslen,strcpy
摘要:1 #include 2 #include 3 #include 4 5 6 // 手动实现 统计宽字符的个数 7 int mywcslen(wchar_t *wstr) 8 { 9 int i = 0;10 for (;*wstr!=L'\0';)11 {12 ... 阅读全文

posted @ 2015-05-14 20:23 Dragon-wuxl 阅读(298) 评论(0) 推荐(0)

自己实现可变参数printf函数 ------ myprintf
摘要:1 #include 2 #include 3 #include 4 5 void myprintf(char *ptstr,...) // 可变参数 6 { 7 va_list ap;//作为起始点 8 va_start(ap,ptstr);// 从起始点开始读取ptstr 9... 阅读全文

posted @ 2015-05-14 10:57 Dragon-wuxl 阅读(785) 评论(0) 推荐(0)

管道与字符串,判断QQ是否运行以及QQ当前运行的个数
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 6 int exeshell(char *cmd,char *result)// cmd为传递的指令 result 为返回的结果 7 { 8 ... 阅读全文

posted @ 2015-05-14 08:52 Dragon-wuxl 阅读(215) 评论(0) 推荐(0)

调用sprintf函数将实数打印到字符串及手动实现实数转字符串函数 ------ ftoa
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 5 char *ftoa(double db, char *str);// 手动实现将实数转化为字符串 6 7 // 实数转字符串 8 void main() 9 {10 ... 阅读全文

posted @ 2015-05-13 16:43 Dragon-wuxl 阅读(637) 评论(0) 推荐(0)

调用函数实现字符串转实数以及手动实现该功能 ----- atof
摘要:1 #include 2 #include 3 4 5 double myatof(char *str);// 手动实现 将字符串转化为实数 6 7 void main() 8 { 9 char str[30] = "123.3456";10 double db = atof... 阅读全文

posted @ 2015-05-13 14:45 Dragon-wuxl 阅读(292) 评论(0) 推荐(0)

调用函数实现整数和字符串的互转以及手动实现该功能 ----- _itoa, atoi
摘要:1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 6 int myatoi(char *str);// 手动实现 字符串 转 整数 7 8 char * myitoa(int num, char * str... 阅读全文

posted @ 2015-05-13 10:49 Dragon-wuxl 阅读(152) 评论(0) 推荐(0)

调用函数实现字节拷贝以及手动使用下标法和指针法实现 ------ _memccpy
摘要:1 #include 2 #include 3 #include 4 5 /* 6 函数名: _memccpy 7 功 能: 从源source中拷贝n个字节到目标destin中,遇到字符 ch 就提前结束; 8 用 法: void *memccpy(void *des... 阅读全文

posted @ 2015-05-13 09:02 Dragon-wuxl 阅读(154) 评论(0) 推荐(0)

从buf所指内存区域的前count个字节查找字符ch以及手动使用指针法和下标法实现 ------ memchr
摘要:1 #include 2 #include 3 #include 4 #include 5 6 /* 7 功能:从buf所指内存区域的前count个字节查找字符ch。 8 9 说明:当第一次遇到字符ch时停止查找。如果成功,返回指向字符ch的指针;否则返回NULL。10 */1... 阅读全文

posted @ 2015-05-12 16:46 Dragon-wuxl 阅读(203) 评论(0) 推荐(0)

比较内存区域buf1和buf2的前count个字节但不区分字母的大小写及手动使用指针法实现 ------ _memicmp
摘要:1 #include 2 #include 3 #include 4 #include 5 6 // _memicmp 判定这片内存内容相同还是不同 7 8 int pointmemicmp(const void * _Buf1, const void * _Buf2, size_t _... 阅读全文

posted @ 2015-05-12 16:25 Dragon-wuxl 阅读(487) 评论(0) 推荐(0)

调用函数实现内存拷贝以及手动实现内存拷贝 ------ memmove
摘要:1 #include 2 #include 3 #include 4 #include 5 6 7 // memmove 是按整体拷贝 memcpy 是按字节拷贝 8 void * mymemmove(void * _Dst,const void * _Src,size_t _Size);... 阅读全文

posted @ 2015-05-12 14:53 Dragon-wuxl 阅读(181) 评论(0) 推荐(0)

调用函数实现内存清零以及手动使用下标法和指针法实现内存清零 ------ memset
摘要:1 #include 2 #include 3 #include 4 5 void * indexmemset(void * _Dst, int _Val, size_t _Size);// 下标法实现数据清零 6 void * pointmemset(void * _Dst, int _Val... 阅读全文

posted @ 2015-05-12 11:32 Dragon-wuxl 阅读(273) 评论(0) 推荐(0)

调用函数实现内存拷贝以及手动使用下标法和指针法实现内存拷贝 ------ memcpy
摘要:1 #include 2 #include 3 #include 4 5 6 void * indexmemcpy(void * _Dst,const void * _Src, unsigned int _Size);// 下标法自己实现内存拷贝 7 void * pointmemcpy(vo... 阅读全文

posted @ 2015-05-12 10:58 Dragon-wuxl 阅读(205) 评论(0) 推荐(0)

二级指针之锯齿数组
摘要:#include #include #define N 10void main(){ int **pp = malloc(sizeof(int *)*(2 * N - 1)); for (int i = 0; i < N;i++) { pp[i] = malloc(sizeof(int... 阅读全文

posted @ 2015-05-11 10:45 Dragon-wuxl 阅读(168) 评论(0) 推荐(0)

导航