zoukankan      html  css  js  c++  java
  • C++中指针乱了!如何解决 遥远的青苹果

       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重置为原来的值

  • 相关阅读:
    pyQt5新手教程 (二)开始你的旅程-编写
    未来写作
    电脑使用问题
    cad学习问题
    chm制作
    github学习之路
    python解决实际问题
    英语学习
    经济学
    通过playgrounds程序学习swift语言及思想
  • 原文地址:https://www.cnblogs.com/lixinhai/p/2622619.html
Copyright © 2011-2022 走看看