Explain the difference between heap and stack memory in C.
user
**Heap:**
* Dynamically allocated memory.
* Allocated and deallocated at runtime using malloc() and free().
* Slower access compared to stack.
* Can lead to memory leaks if not managed properly.

**Stack:**
* Fixed-size memory used for local variables and function calls.
* Automatically allocated and deallocated.
* Faster access compared to heap.
* Limited space, can lead to stack overflow errors.
assistant