Last active
May 3, 2017 16:49
-
-
Save krishnan793/e8caf6f5cb314b340994 to your computer and use it in GitHub Desktop.
Use the entire RAM space using dynamic memory allocation. Will also display the memory it is using.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
/*Struct flood require 256*4=1Kb */ | |
struct flood{ | |
long int a[256]; | |
}*temp; | |
void main() | |
{ | |
long int k=sizeof(struct flood); | |
while(1) | |
{ | |
temp=(struct flood *)malloc(sizeof(struct flood)); | |
printf("%0.2f Mb\n",(float)k/(1024*1024)); | |
k=k+1024; | |
if(temp==NULL) | |
printf("Memory Full\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment