Help
Ron Ueberschaer
ubi at sri-unix.ARPA
Tue Nov 18 05:15:56 AEST 1986
In article <408 at ethz.UUCP> lubich at 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 at sri-unix.UUCP
{know world}!{hplabs,rutgers}!sri-unix!ubi
More information about the Comp.lang.c
mailing list