Question: ` ` ` p = malloc ( n ) reserves enough space, in the heap, for n char values; p points at it . /
p mallocn reserves enough space, in the heap, for n char values; p points at it
makestrch n Return a new array containing a int mainvoid
string containing n copies of ch char str makestrX;
effects: allocates heap memory caller must free TRACE:
char makestrchar ch int n assert strcmpstrXXXX;
char p mallocn ; allocate n chars.
for int i ; i n; i write to them.
pi ch;
pn; nullterminate the string
TRACE:
return p;
Draw memory diagrams at TRACE: and TRACE:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
