C program to allocate memory

#include <stdlib.h>
#include <stdio.h>

int main()
{
long count=2;
char * mem;
while(1)
{
printf("allocated %ld bytes\n", count);
if((mem=(char *) malloc(count))== NULL) exit(1);
/*free(*mem); */
count*=2;
}
}

No comments:

Post a Comment

Compressed tar archive

There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...