Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!mips!prls!pyramid!voder!apple!snorkelwacker!bloom-beacon!eru!hagbard!sunic!liuida!prodix!martin From: martin@prodix.liu.se (Martin Wendel) Newsgroups: comp.lang.c Subject: stupid compilers Message-ID: Date: 31 Aug 90 09:08:27 GMT Organization: y Lines: 40 Can anyone explain to me why this piece of code is O to run: #include #include main() { char line[]; char *tmp = "1234"; strcpy(line, tmp); printf("%s\n", line); } when this pboduce a segmentation fault: #include #include main() { char *line; char *tmp = "1234"; strcpy(line, tmp); printf("%s\n", line); } I have a sparcstation 1+ and run SUNOS 4.03 and I have tried the Sun C compiler and the GNE C compiler with and without the -ansi flag set, but they all behave the same. Thanks in advance. _____________________________________________________________ < Martin Wendel > martin@solix.udac.uu.se > > Postmaster at UDAC < Martin.Wendel@UDAC.UU.SE < < Uppsala University - > Postmaster@UDAC.UU.SE > > Data Centre < Phone: 018 - 18 77 80 < < Sysslomansgatan 21 > Int: +46 18 18 77 80 > > S-750 02 Uppsala <---------------------------------< < SWEDEN > /\/\ \ \/ / > >_________________________<___________/ /\ \_\/\/___________<