Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!image.soe.clarkson.edu!news From: gld2@clutx.clarkson.edu (E.W.D, ,0,0) Newsgroups: comp.lang.c Subject: Re: stupid compilers Message-ID: <1990Aug31.205306.13861@sun.soe.clarkson.edu> Date: 31 Aug 90 20:53:06 GMT References: <163@prodix.liu.se> Sender: news@sun.soe.clarkson.edu Reply-To: gld2@clutx.clarkson.edu Distribution: usa Organization: Clarkson University, Potsdam, NY Lines: 31 From article <163@prodix.liu.se>, by martin@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@rodan.acs.syr.edu RD 1 Box 66 Cato, New York 13033 315 437 0215