On 07 Mar 2007 18:36:56 -0800, Chetan Nanda <[EMAIL PROTECTED]> wrote:
>
> 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. But it do not crash. I am using
> GCC as compiler.
>
> ~nandac
>
You are crossing the memory bounds and corrupting the memory block which
might have been allocated to other parts of your program or some other
program. It might crash the other programs or applications. So behavior is
undefined.
--
Regards
Sumit Chawla ("eNetra : Hail the Invention")
"Computers are useless. They can only give you answers.":Pablo Picasso
[Non-text portions of this message have been removed]