Should I free memory before exit?
问题 Should I free all my mallocated memory when I am exiting program in the due of error? something = (char**) malloc (x * sizeof(char*)); for (i = 0; i < x; i++) something[i] = (char*) malloc (y + 1); ... if (anything == NULL) { printf(\"Your input is wrong!\"); // should I free memory of every mallocated entity now? exit(1); } else { // work with mallocated entities ... free(something); // it must be here system(\"pause); } 回答1: It depends on the OS. Best practice I'd say you should explicitly