About 0x ??? in VC ???? Unhandled exception: 0xc0000005

Source: Internet
Author: User

Reproduced in: http://hi.baidu.com/andywangcn/item/4b5a31594a06f1c8d2e10cc2

"An unhandled exception occurred at 0x00414030 in test.exe: 0xc0000005: The write location is 0 xfeeefeee."Appears0xc0000005The reason is generally because no memory is allocated or the memory is invalid,

For example:

# Include "stdafx. H"
# Include <string>
Using namespace STD;

Int _ tmain (INT argc, _ tchar * argv [])
{

String * s = NULL;
S = new string ();
Delete S;

If (s! = NULL)
{
* S = "test"; // This step will cause an exception.
}

Return 0;
}

Although S has been deleted, but s value is not null, if statement judgment will be invalid, this is a common error for beginners!

To prevent this error, you can define a macro to handle the delete operation.

# DEFINE _ Delete (OBJ) if (OBJ! = NULL) {Delete OBJ, OBJ = NULL ;}

Use this macro to prevent similar errors.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.