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