Reply embedded...

> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
> Chetan Nanda
> Sent: Wednesday, March 07, 2007 8:37 PM
> To: [email protected]
> Subject: [c-prog] C Prog help
> 
> Hi All,
> Acn anybody explain me the behavior of the following program.
> 
> #include <stdio.h>
> int main()
> {
>     char *dst = (char *) malloc(4);
>     strcpy(dst, "This is a nice palace");
> 
>      exit(0);
> }
> 
> This is a clear case of memory corruption. 

Correct.  And the result is "undefined behavior".


> But it do not crash. I am using GCC as compiler.

Crashing is one of the possible behaviors, so is "appearance to work
normally".  

> 
> ~nandac

HTH
Shyan



Reply via email to