#include #include #include main(int argc, char **argv) { size_t sz; char *p; sz=(size_t)(strtol( argv[1], (char **)NULL, 0 )*1024); p=malloc(sz); printf(p!=NULL?"ok: %d %dK %dM\n":"fail: %d %dK %dM\n", sz, sz/1024, sz/1024/1024); if (p) strcpy(p,"Hello, World!"); else perror("malloc"); if (NULL == (p=realloc(p, sz*2))) perror("realloc"); else puts(p); while(1) { *p++=0x00; } }