A little bit of __

Source: Internet
Author: User

Problem: Compile, link is OK, run at the end of debug error errors, Damage:after Normal block (#187) at 0x00033160

Source:

Child function problem, independent of main function, Have[pn][rn],need[i][j],offer[rn of main function is passed, return an integer value

int Issafe (Vector < vector<int> >& have, vector < vector<int> >& need, Vector <int>& Amp Offer

{
int safe=0;

Vector < vector<int> >have1 (PN);//global variable: PN,RN
Vector < vector<int> >need1 (PN);
Vector <int> Offer1 (RN);

for (int i=0; i<pn; i++)
{
for (int j=0; j<rn; j + +)
{
HAVE1[I][J]=HAVE[I][J]; Have1[i].push_back (Have[i][j]);
Need1[i][j]=need[i][j];//need1[i].push_back (Need[i][j]);
}
}

return safe;

}

Cause: The main reason for this is the incorrect use of dynamically allocated memory. The have1 vector only knows the one-dimensional vector that contains the PN, but does not know how many elements each of the one-dimensional vectors are, so have1[i][j]=have[i][j]; is wrong; this accesses the wrong memory---the content of that address is unknown.
There is debug error, VC detected this error message. --

Resolution: Green part changed to red part

Reference http://www.programfan.com/club/showpost.asp?id=146259&t=o:

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.