摘要:1 #include 2 #include 3 using namespace std; 4 class A 5 { 6 public: 7 /* 这段代码运行会崩溃,构造器初始化类的数据成员,只跟数据成员的声明的先后顺序有关 8 A(char * ps) 9 :name(ps),len(strlen(name.c_str())){} 10 11...
阅读全文
摘要:1 #include 2 #include 3 4 using namespace std; 5 /* 6 题目:读字符串 char buf[100] = “xxxx:yyyy:zzzz:aaaa:bbb”.按:进行分解到,string 数组中去。 7 */ 8 int main(void) 9 { 10 char buf[100] = "xxxx:yyyy:zz...
阅读全文
摘要:1 #include 2 #include 3 #include 4 /* 5 双向链表,创建,查找,删除 6 */ 7 //定义结构 8 typedef struct stu 9 { 10 char name[30]; 11 char sex; 12 int num; 13 float math; 14 float chinese...
阅读全文
摘要:1 #include 2 /* 3 编码实现字符串转整型的函数(实现函数 atoi 的功能)。如将字符串“123”转化为 123, 4 “-0123”转化为-123 5 */ 6 int myatoi(const char *p) 7 { 8 int val = 0; 9 int sign; 10 while(*p == ' '||*p == '\t'...
阅读全文