+ 2

Explain the code below

ptr = malloc(10*sizeof(*ptr)); /* a

1st Apr 2021, 2:09 AM
Zenith Dabarera
2 Answers
+ 5
allocate 10 * (size of whatever type ptr points to) bytes on the heap
1st Apr 2021, 2:34 AM
durian
durian - avatar
+ 2
Share link to complete version of the code. As it is, there is no type definition for variable <ptr> and that line isn't getting past compile phase.
1st Apr 2021, 3:02 AM
Ipang