时间:2021-05-19
复制代码 代码如下:
#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
-------------------
请按任意键继续. . .
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
c++回调之利用函数指针示例复制代码代码如下:#includeusingnamespacestd;/******************************
C++有关指针的数据类型和指针运算的小结前面已用过一些指针运算(如p++,p+i等),现在把全部的指针运算列出如下。1)指针变量加/减一个整数例如:p++,p-
C++智能指针shared_ptr分析概要:shared_ptr是c++智能指针中适用场景多,功能实现较多的智能指针。它采取引用计数的方法来实现释放指针所指向的
01++、--运算符重载函数的格式自增运算符和自减运算符是有前置和后置之分的,如:a++//后置自增运算符++a//前置自增运算符b--//后置自减运算符--b
C++的流插入运算符“”是C++在类库中提供的,所有C++编译系统都在类库中提供输入流类istream和输出流类ostream。cin和cout分别是istre