旅途

如果想飞得高,就该把地平线忘掉

指针的前置++与后置++的区别

指针的前置++与后置++的区别

 

//代码片段一:

int arr[] = {1,2,3,4,5,6,7,8,9,10};

int* parr1 = arr;

 

int A = *parr1++;

int B = *parr1;

 

cout << "A = " << A << endl;

cout << "B = " << B << endl;

 

输出结果:

 

A = 1;

B = 2;

 

代码片段二:

 

int arr[] = {1,2,3,4,5,6,7,8,9,10};

int* parr1 = arr;

 

int A = *++parr1;

int B = *parr1;

 

cout << "A = " << A << endl;

cout << "B = " << B << endl;

 

输出结果:

 

A = 2 ;

B = 2;

posted on 2007-09-06 01:24 旅途 阅读(278) 评论(0)  编辑 收藏 引用 所属分类: C/C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理