Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!paperboy!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.sys.apple2 Subject: Re: orca/c bug Message-ID: <16345@smoke.brl.mil> Date: 6 Jun 91 02:19:05 GMT References: <3728@kluge.fiu.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 28 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. (d) You must return an integer value from the main() function, or else terminate the program by invoking exit(). (e) realloc() takes two arguments.