home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day10
/
malloc.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-06-08
|
348b
|
20 lines
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
/* allocate memory for a 100-character string */
char *str;
str = (char *) malloc(100);
if (str == NULL)
{
printf( "Not enough memory to allocate buffer\n");
exit(1);
}
printf( "String was allocated!\n" );
free(str);
return 0;
}