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 >
Wrap
Text File
|
1988-11-21
|
437b
|
20 lines
#include "malloc.h"
#include <stdio.h>
/* This is a program which copies too much data into a
malloc buffer */
main()
{
char *string1, *string2;
string1 = malloc(4);
string2 = malloc(6);
strcpy(string2, "12345");
/* about to copy too many characters into string1 */
strcpy(string1, "ABCDEFGHIJ");
printf("string1 = >%s<\n", string1);
printf("string2 = >%s<\n", string2);
free(string1);
free(string2);
}