stupid compilers

E.W.D, ,0,0 gld2 at clutx.clarkson.edu
Sat Sep 1 06:53:06 AEST 1990


>From article <163 at prodix.liu.se>, by martin at prodix.liu.se (Martin Wendel):
> Can anyone explain to me why this piece of code is OK to run:
> main()
> {
>    char line[];
>    char *tmp = "1234";
>    strcpy(line, tmp);
>    printf("%s\n", line);
> }

main ()
{
   char line[];
   char *tmp = "1234\336\255\276\357";
   int   innocent = 030073335276;

   printf("wanted %08X\n", innocent);
   strcpy(line, tmp);
   printf("got    %08X\n", innocent);
}


wanted C0EDBABE
got    DEADBEEF

(in certain endian contexts).

Eliot W. Dudley                       edudley at rodan.acs.syr.edu
RD 1 Box 66
Cato, New York 13033                  315 437 0215



More information about the Comp.lang.c mailing list