*a++ 和 *++a

++ 的优先级高于 *
*a++ 等价于 *(a++)
*++a 等价于 *(++a);

#include <iostream>
using namespace std;

int main()
{
	int test[] = {1, 2, 3, 4, 5};
	int *a = test;
	cout << *a++ << endl;		// 输出1
	cout << *a << endl;	        // 输出2
	cout << *++a << endl;		// 输出3
	cout << *a << endl;	        // 输出3
}
posted @ 2021-08-02 09:59  CoolGin  阅读(380)  评论(0编辑  收藏  举报