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

int main(){
 char *ptr, c;
 unsigned long i,n;
 
 printf("Enter number of KB you want to allocate: ");
 scanf("%lu",&n);
 
 printf("Allocating %lu Kbytes......\n",n);
 printf("press to fill\n");
 while((c = getchar()) != '\n' && c != EOF);
 scanf("%c",&c);
 ptr=(char*)malloc(n*1024);
 if (ptr==NULL){
   printf("ERROR!Memory not allocated!");
   exit(0);
 }
 printf("Filling into memory.....\n");
 for (i = 0; i < n*1024; i++){
    ptr[i] = 'a';
//	printf("\r%li%%	", i*100/(n*1024));
 }
 printf("\n");
 printf("press to finish\n");
 //while((c = getchar()) != '\n' && c != EOF);
 scanf("%c",&c);
 printf("Free memory.\n");
 free(ptr);
 return 0;
}
