欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

new 数组越界 系统不会报错 博客分类: c++  

程序员文章站 2024-03-19 10:16:40
...
/** \brief
    测试 数组越界 , 系统是否有报错
 *
    测试结果: 不报错
 *
 * \param
 * \param
 * \return
 *
 */
#include <iostream>



using std::cout ;

int main(){

    int * ary = new int [100];

    std::cout << "ary[101] = " << ary[101] << std::endl;

    std::cin.get();

    std::cout << "ary[1000] = " << ary[1000] << std::endl;

    std::cin.get();

    return 0;
}

 

结果:
ary[101] = 0

ary[1000] = 0


Process returned 0 (0x0) execution time : 1.685 s
Press ENTER to continue.