DarkSE 发表于 2016-10-29 08:56:29

自定义数组越界

#include <string>
#include <iostream>
using namespace std;
struct HuffmanCode
{
        char data;
        int power;
        char str;
};
int main()
{
        HuffmanCode *huffman = new HuffmanCode ;//= new HuffmanCode;
        huffman.data = 6;
        cout<<&(huffman)<<endl;
        huffman.str = 'a';
        cout<<sizeof(huffman)<<endl;
        delete []huffman;
        return 0;
}
想请问一下为什么这个代码不会报错,可以运行通过

yslieff 发表于 2016-10-30 10:25:36

C不会对数组是否越界进行检查
页: [1]
查看完整版本: 自定义数组越界