ALEXKK2011

The Technical Side of alexKK2011
  博客园  :: 新随笔  :: 订阅 订阅  :: 管理

2011年2月24日

摘要: #include <iostream>using namespace std;void swapf(char* a, char* b){ int n1 = *a, n2 = *b; n1=n1+n2; n2=n1-n2; n1=n1-n2; *a=n1, *b=n2;};void main(){ char x ='a', y='B'; char *px = &x, *py = &y; char &... 阅读全文

posted @ 2011-02-24 22:18 alexkk2011 阅读(164) 评论(0) 推荐(0) 编辑

摘要: #include <iostream>using namespace std;char* GetMem(void){ char p[] = "hello"; return p;};void main(){ char c[] = "a"; char* ptr = c; ptr = GetMem(); //strcpy(ptr,"hello!"); cout << ptr << endl; cout ... 阅读全文

posted @ 2011-02-24 18:45 alexkk2011 阅读(108) 评论(0) 推荐(0) 编辑

摘要: #include <iostream>using namespace std;void GetMem(char** p, int n){ *p = (char*)malloc(sizeof(char)*n);};void main(){ char c[] = "a"; char* ptr = c;//NULL; GetMem(&ptr, 100); strcpy(ptr,"hello!"); co... 阅读全文

posted @ 2011-02-24 17:46 alexkk2011 阅读(170) 评论(0) 推荐(0) 编辑

摘要: 作者:mxdxm转自:http://mxdxm.javaeye.com/blog/655770const是C++中引入的一个新的关键字,它为C++编程带来了很大的方便。指向const对象的指针和const指针是两个名字很接近的概念,对于初学者来说非常容易搞混,这里对它们进行区分。 指向const对象的指针 可以这样理解指向const对象的指针: 指向const对象的指针就是一个指针,不能通过它来修改它所指向的对象的值 · 声明方法:const int *p; const对象在初始化后是不允许对其值进行修改的,因此,我们不能用一个普通指针指向一个const对象,即下面的赋值会引起编译错 阅读全文

posted @ 2011-02-24 13:06 alexkk2011 阅读(378) 评论(0) 推荐(0) 编辑