首页 > 其他 > 详细

crash的方法(不断更新中)

时间:2014-07-07 20:29:22      阅读:341      评论:0      收藏:0      [点我收藏+]
#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的方法(不断更新中)

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!