#include <stdio.h> #include <stdlib.h> int main () { char *s1; char *s2; s1 = (char *) malloc (1); strcpy (s1, "Kangaroo Wallaroo Wallaby"); s2 = (char *) malloc (1); strcpy (s2, "Platypus"); printf ("%s\n", s1); return 0; }
char *readLine ();
When called, it should read in the next line of input from the keyboard. It should return the line, with the <CR> removed. Unlike gets, fgets, and the version of readline in the lecture notes, this version does not take any parameters. As a result, this version must allocate the memory to hold the input. You should do this in a way that wastes no memory. The returned address should point to a chunk exactly the size of what is needed to hold the returned string (including the terminating nul character). Any extra memory that is allocated during execution of the readline function should be freed before the function returns.