码迷,mamicode.com
首页 > 其他好文 > 详细

crash的方法(不断更新中)

时间:2014-07-07 20:29:40      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   div   

#include <iostream>
using namespace std;

int main()
{
#if 0
    //devide by 0
    int i = 1;
    int j = 0;
    double d = i/j;
#endif    

#if 1
    //allocate large memory, NOK
    char* pc = new char[1000000000];
#endif

#if 0
    //change const memory, OK
    char* pc1 = "stack";
    pc1[0] = a;
    cout << pc1 << endl;
#endif

#if 0
    //access invalid address£¬ OK
    char pc3[] = {a, b, c};
    pc3[3] = d;    
    cout << pc3 << endl;
#endif

#if 0 
    //stack overflow, NOK
    char pc4[8];
    cout << "Please enter yoour name: " << endl;
    cin >> pc4; //enter AAAAAAAAAAAAAAAAAAAAAAA
    cout << "Your name is: " << pc4 << endl;
#endif

#if 0
    //delete pointer not from new, NOK
    int i;
    int* pi = &i;
    delete pi;
#endif

}

 

crash的方法(不断更新中),布布扣,bubuko.com

crash的方法(不断更新中)

标签:style   blog   color   os   io   div   

原文地址:http://www.cnblogs.com/dracohan/p/3813141.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!