home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_02 / v7n2046a.txt < prev    next >
Text File  |  1988-11-21  |  437b  |  20 lines

  1. #include "malloc.h"
  2. #include <stdio.h>
  3.  
  4. /* This is a program which copies too much data into a
  5.    malloc buffer */
  6.  
  7. main()
  8. {
  9.     char *string1, *string2;
  10.     string1 = malloc(4);
  11.     string2 = malloc(6);
  12.     strcpy(string2, "12345");
  13.     /* about to copy too many characters into string1 */
  14.     strcpy(string1, "ABCDEFGHIJ");
  15.     printf("string1 = >%s<\n", string1);
  16.     printf("string2 = >%s<\n", string2);
  17.     free(string1);
  18.     free(string2);
  19. }
  20.