Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!austin From: austin@bucsf.bu.edu (Austin Ziegler) Newsgroups: comp.lang.c Subject: Re: Help... Message-ID: <39902@bu-cs.BU.EDU> Date: 10 Oct 89 02:07:14 GMT References: <731@carroll1.UUCP> Sender: daemon@bu-cs.BU.EDU Organization: Boston University College of Engineering Lines: 27 On 9 Oct 89 23:26:06 GMT, dnewton@carroll1.UUCP (Dave 'Yes, I'm weird' Newton) said: Dave> Relay-Version: version B 2.10.3 4.3bds beta 6/6/85; site bu-cs.BU.EDU Dave> Date-Received: 10 Oct 89 01:39:31 GMT Dave> Why doesn't this work? Dave> ========================== Dave> #include Dave> main () Dave> { Dave> char h[]; Dave> scanf ("%s", h); Dave> printf ("%s\n", h); Dave> } Dave> ========================== Dave> It seems innocent enuf, but just prints garbage. I'm missing something Dave> obvious, but I'll be darned if I know what it is. I don't know, but I just tried it. One possibility is to strcat a \0 to the end of h before printf'ing h. Otherwise, you can get the same result from char *h, and not get too many problems. \|/ Elminster, Sage of Shadowdale -*- /|\ austin@bucsf.bu.edu