home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_10_05
/
1005074a
< prev
next >
Wrap
Text File
|
1991-09-26
|
419b
|
26 lines
/*
* Listing 1 -- Error by reading a freed pointer
*/
#include <stdlib.h>
#include <assert.h>
void main() {
int *ip;
int n;
/* allocate an integer */
ip = malloc(sizeof(int));
assert(ip != NULL);
/* initialize the integer */
(*ip) = 1;
/* deallocate the integer */
free(ip);
/* use the deallocated integer */
n = 3 * (*ip);
printf("n may or may not equal 3 (n == %d)\n",n);
}