KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
#include <stdio.h> #include <string.h> #include <stdlib.h> char* f(void) { char *x; x = malloc(sizeof(char) * 4); strcpy(x, "abc"); return(x); } int main(void) { char *a; a = f(); printf("%s", a); free(a); return(0); } Does the variable x in the function have to be freed? If so, how is that possible when I need to return it?
Tags (comma-separated)
Save Edits
Cancel