Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!rex!uflorida!kluge!serss0!acmfiu From: acmfiu@serss0.fiu.edu (albert chin) Newsgroups: comp.sys.apple2 Subject: Re: orca/c bug Message-ID: <3768@kluge.fiu.edu> Date: 7 Jun 91 02:59:22 GMT References: <3728@kluge.fiu.edu> <16345@smoke.brl.mil> Sender: news@kluge.fiu.edu Organization: Florida International University, Miami Lines: 36 In article <16345@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: }In article <3728@kluge.fiu.edu> acmfiu@serss0.fiu.edu (ACMFIU) writes: }}int }}main (void) }}{ }} char *foo; }} foo = malloc (10); }} strcpy (foo, "abc"); }} printf ("%s\n", foo); }} foo = realloc (10 + 1); }} printf ("%s\n", foo); }}} } }The above program is utterly wrong, and it is a wonder that it doesn't }crash your system. } }(a) You must #include or else properly declare malloc() and }realloc() before invoking them. } }(b) You must #include or else properly declare printf() before }invoking it. } }(c) You must #include or else properly declare strcpy() before }invoking it. i assumed people would do this. }(d) You must return an integer value from the main() function, or else }terminate the program by invoking exit(). } }(e) realloc() takes two arguments. this was a typo on my part. the program will still not work when you change the realloc to 'foo = realloc (foo, 10 + 1);' albert