源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

基于C++输出指针自增(++)运算的示例分析

  • 时间:2020-11-08 23:47 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:基于C++输出指针自增(++)运算的示例分析
[u]复制代码[/u] 代码如下:
#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 ------------------- 请按任意键继续. . .
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部