// loads a file into memory
void load_file()
{
char *data = "This is so data";
printf("function: %s\n", data);
}
Will the above code leak memory? Do I have call free(data)? Why or why not?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It cannot leak because you did not dynamically allocate it.
datais a string literal and not a dynamically allocated array of characters.