segfault

A segfault occurs when a program attempts to access a memory location that is not allowed to access, or attempts to access a memory location in a way is not allowed.

// segfault.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string.h>

int _tmain(int argc, _TCHAR* argv[])
{
    char a[2];
    char b[] = "Hello world!";

    memcpy(a, b, strlen(b));
    return 0;
}

上述示例也就是我们常说的越界访问!

posted @ 2013-05-14 18:33  薛定谔の喵  阅读(223)  评论(1)    收藏  举报