Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-unix!ubi From: ubi@sri-unix.ARPA (Ron Ueberschaer) Newsgroups: comp.lang.c Subject: Re: Help Message-ID: <550@sri-unix.ARPA> Date: Mon, 17-Nov-86 14:15:56 EST Article-I.D.: sri-unix.550 Posted: Mon Nov 17 14:15:56 1986 Date-Received: Mon, 17-Nov-86 21:29:36 EST References: <408@ethz.UUCP> Reply-To: ubi@sri-unix.UUCP (Ron Ueberschaer) Organization: SRI, Menlo Park, CA. Lines: 34 Keywords: memory In article <408@ethz.UUCP> lubich@ethz.UUCP (Hannes Lubich) writes: >Well, I'm trapped. > > while (fgets (teststring, 100, myfptr) != NULL) >.... > fclose (myfptr); > >I get 'Illegal instruction' when returning (both 1 and 0), if >.... >Furthermore when I declare teststring as : char teststring[]; ^^^^^^^^^^^^^^^^^ >the above result appears but when I try to declare it as >char *teststring; I get a 'Bus error' at once. ^^^^^^^^^^^^^^^^ >.... > {known world}!cernvax!ethz!lubich Well, I don't know about the problem of return status, but I *do* know that you need to allocate some memory for "teststring". Both declarations above only allow teststring to point to the location of a previously defined character (or array thereof). It is possible that the empty brackets declaration finds an unallocated byte of memory and initializes teststring to point there, thus explaining the different results you observed. Why not try this declaration: char teststring[100]; Good luck! Ron Ueberschaer ubi@sri-unix.UUCP {know world}!{hplabs,rutgers}!sri-unix!ubi