1: // TestArrayPtr.cpp : Defines the entry point for the console application.
2: //
3:
4: #include "stdafx.h"
5: #include <stdio.h>
6: #include <iostream>
7: using namespace std;
8:
9: int _tmain(int argc, _TCHAR* argv[])
10: {
11:
12:
13: int* p_Jtobus = new int[6];
14:
15: for ( int i=0;i<6;i++)
16: {
17:
18: p_Jtobus[i]=i;
19:
20: }
21: cout<<"小段程序一"<<endl;
22: for ( int i=0;i<6;i++)
23: {
24: int s= * p_Jtobus;
25: p_Jtobus++;
26:
27: cout<<"out putA"<<i<<"输出的值是"<<s<<endl; //iostream
28:
29: }
30: cout<<"小段程序二"<<endl;
31: for ( int i=0;i<6;i++)
32: {
33: int s= * p_Jtobus;
34: p_Jtobus++;
35:
36: cout<<"out putB"<<i<<"输出的值是"<<s<<endl; //iostream
37:
38: }
39:
40: char filename[30];
41: scanf("%s", filename);
42:
43: return 0;
44: }
指针乱啦
第一次 和第二次
如何让他恢复到以前
各位看官如何解决呢!
期待你的静态答案!
第二个for之前
没有把p_Jtobus重置为原来的值
原文链接: https://www.cnblogs.com/lixinhai/archive/2012/08/04/2622619.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/57894
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!