When you call malloc() to allocate memory for a local
pointer, do you have to explicitly free() it?

Answers were Sorted based on User's Feedback



When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?..

Answer / shruti

yup.. we have to explicitly free it..
otherwise it results in "dangling pointer"..

Is This Answer Correct ?    20 Yes 0 No

When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?..

Answer / guest

Yes you have to.

Is This Answer Correct ?    13 Yes 1 No

Post New Answer

More C Interview Questions

How can you tell whether a program was compiled using c versus c++?

0 Answers  


can we access one file to one directory?

1 Answers  


Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: “jack and jill went up a hill” Return Value: “kcaj dna llij tnew pu a llih”

5 Answers   Mind Tree,


Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4 1) Quick Sort 2) Bubble Sort 3) Merge Sort

7 Answers  


How are variables declared in c?

0 Answers  


how to print this sereis 2 4 3 6 5..........?

3 Answers  


What happens if a header file is included twice?

0 Answers  


what is c?

13 Answers   Tech Mahindra,


write a program of bubble sort using pointer?

3 Answers   TCS,


write a program to find the sum of the array elements in c language?

24 Answers   ICT, Infosys, Wipro,


Find the largest number from the given 2 numbers without using any loops and the conditional operator.

2 Answers  


What are the different types of C instructions?

0 Answers   InterGraph,


Categories