Lesson 21 of 23
Dynamic Memory: malloc और free
10 min 35 XP
जब size सिर्फ़ run time पर पता चले, तो malloc से heap memory माँगें। काम खत्म होने पर free से छोड़ें, वरना memory leak होती है।
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.malloc बनाम calloc: calloc memory को शून्य भी करता है; realloc उसका size बदलता है। Stack बनाम heap interview का आम सवाल है।