0

This is simple code:

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

void cleanUp(){
    printf("I have to do free up memory\n");
}

int main(){

    char *temp;

    temp = (char *)malloc(10*sizeof(char)); 

    atexit(cleanUp);

    exit(0);

    free(temp);

    return 0;
}

When the program will exit, how can I free up the memory. Function 'cleanUp' have no parameter. So how can I free up the memory in function 'cleanUp' for no memory leak.

o_O
  • 51
  • 7

0 Answers0