KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When a function returns, is the memory allocated via malloc freed? Or can it still be accessed in the main() function using pointers? eg. void function(int *a) { a=(int *)malloc(sizeof(int)); *a=10; } int main() { int *num; function(num); printf("%d",*num); return(0); } Can the integer stored in a be accessed by main() here?
Tags (comma-separated)
Save Edits
Cancel