Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <stdbool.h>
- int eat(long total,int chunk){
- long i;
- for(i=0;i<total;i+=chunk){
- short *buffer=malloc(sizeof(char)*chunk);
- if(buffer==NULL){
- return -1;
- }
- printf("nDATA=%d",*buffer);
- memset(buffer,0,chunk);
- }
- return 0;
- }
- int main(int argc, char *argv[]){
- int i,chunk=1024;
- long size=10000;
- printf("Got %ld bytes in chunks of %d...n",size,chunk);
- if(eat(size,chunk)==0){
- printf("Done, press any key to free the memoryn");
- getchar();
- }else{
- printf("ERROR: Could not allocate the memory");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement