www.pudn.com > c.rar > malloc.c
#include#include 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; }