Old*_*loi 0 c++ visual-studio-2010
我是C++的新手.我通常用C#编程,所以我遇到了数组和循环的麻烦.当我尝试使用循环打印动态数组的内容时,它表示请求区域已损坏...例如,我将让它识别与数组内容一起使用的条件但不打印它的内容:
// Array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
int size=3;
int *p;
int myarray[10];
myarray[3]=4;
p=new int[size];
p[2]=3;
if(myarray[3]==4){
cout << myarray[3] +"/n";
cout << "Why?";
}
else
cout << "Not equal " << endl;
cin.get();
delete [] p;
}
Run Code Online (Sandbox Code Playgroud)
代码看起来很好,除非它应该
cout << myarray[3] << "\n";
Run Code Online (Sandbox Code Playgroud)
不是+
| 归档时间: |
|
| 查看次数: |
155 次 |
| 最近记录: |