Home > Back-end >  C/C problems, run the following code to see what would happen after, why, please explain it in detai
C/C problems, run the following code to see what would happen after, why, please explain it in detai

Time:09-21

Void test ()
{
Char * pBuff=new char [100].
Strcpy (pBuff, "sea rise bright moon");
The delete [] pBuff;
If (pBuff)
{
Strcat (pBuff, "www.baidu.com");
Puts (pBuff);
}
}

Int main ()
{
test();
return 0;
}

CodePudding user response:

Result is unknown, pBuff released, it points to memory is rubbish, if the garbage memory has not been used, can perform well over, if the garbage memory just used by other programs, could cause an exception
  • Related