手机
当前位置:查字典教程网 >编程开发 >C语言 >基于C++输出指针自增(++)运算的示例分析
基于C++输出指针自增(++)运算的示例分析
摘要:复制代码代码如下:#include"stdafx.h"#includeusingnamespacestd;int_tmain(intargc...

复制代码 代码如下:

#include "stdafx.h"

#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

char s[] = "012345678", *p = s;

cout << "s:"<<s<<endl;

cout << "*p++ = " << *p++ << ", *(p++) = " << *(p++) << ", (*p)++ = " << (*p)++ << ", *++p = " << *++p << ", *(++p) = "<< *(++p) << ", ++*p = " << ++*p << ", ++(*p) = "<< ++(*p) << endl;

cout<<"-------------------"<<endl;

char s1[] = "012345678";

p = s1;

cout << endl << "s1:"<<s1<<endl;

cout << "*p = " << *p <<endl;

cout << "*p++ = " << *p++ << endl;

cout << "*p = " << *p <<endl;

cout << "*(p++) = " << *(p++) << endl;

cout << "*p = " << *p <<endl;

cout << "(*p)++ = " << (*p)++ << endl;

cout << "*p = " << *p <<endl;

cout << "*++p = " << *++p << endl;

cout << "*p = " << *p <<endl;

cout << "*(++p) = " << *(++p) <<endl;

cout << "*p = " << *p <<endl;

cout << "++*p = " << ++*p << endl;

cout << "*p = " << *p <<endl;

cout << "++(*p) = " << ++(*p) <<endl;

cout<<"-------------------"<<endl;

system("pause");

return 0;

}

输出:

s:012345678

*p++ = 3, *(p++) = 3, (*p)++ = 2, *++p = 4, *(++p) = 4, ++*p = 4, ++(*p) = 4

-------------------

s1:012345678

*p = 0

*p++ = 0

*p = 1

*(p++) = 1

*p = 2

(*p)++ = 2

*p = 3

*++p = 3

*p = 3

*(++p) = 4

*p = 4

++*p = 5

*p = 5

++(*p) = 6

-------------------

请按任意键继续. . .

【基于C++输出指针自增(++)运算的示例分析】相关文章:

C++函数重载的深入解析

C语言运算符优先级列表(超详细)

C/C++实现矩阵的转置(示例代码)

基于C++中常见内存错误的总结

基于SVN源码服务器搭建(详细教程分析)

指针与const限定符的使用分析

基于C语言指令的深入分析

虚函数与纯虚函数(C++与Java虚函数的区别)的深入分析

关于C语言指针赋值的问题详解

基于C++全局变量的声明与定义的详解

精品推荐
分类导航