正在加载图片...
-10- Problem 3:Function Trace (15 points) Draw the state of memory at the point indicated.Be sure to indicate clearly the Stack and Heap. Also,clearly label any orphaned memory,and draw an'X'through any stack frames that are no longer active.You do not have to draw the Data Segment(where string constants are stored). #include "genlib.h" #include "strlib.h" void Endive(int ***joann,int **simca,int *lydia,int *charlie,char **delia); void Chevril(char **nigella); main() string julia; int jacques; int **martin; julia Copystring("hi"); jacques 3; martin GetBlock(jacques sizeof(int *)) martin[0]GetBlock(jacques sizeof(int)); Endive(&martin,martin,*martin,&jacques,&julia); void Endive(int **joann,int **simca,int *lydia,int *charlie,char *delia) int i; for (i=0;i<*charlie;i++) if(i号3==2) *(simca i)=GetBlock(sizeof(int)); else *lydia++*charlie i; *(*joann)[2]=***joann 2; Chevril(delia); DRAW THE STATE OF MEMORY HERE void Chevril(char **nigella) *nigella Concat(*nigella,"there"); Write your answer on the next page.– 10 – Problem 3: Function Trace (15 points) Draw the state of memory at the point indicated. Be sure to indicate clearly the Stack and Heap. Also, clearly label any orphaned memory, and draw an 'X' through any stack frames that are no longer active. You do not have to draw the Data Segment (where string constants are stored). #include "genlib.h" #include "strlib.h" void Endive(int ***joann, int **simca, int *lydia, int *charlie, char **delia); void Chevril(char **nigella); main() { string julia; int jacques; int **martin; julia = CopyString("hi"); jacques = 3; martin = GetBlock(jacques * sizeof(int *)); martin[0] = GetBlock(jacques * sizeof(int)); Endive(&martin, martin, *martin, &jacques, &julia); } void Endive(int ***joann, int **simca, int *lydia, int *charlie, char **delia) { int i; for (i = 0; i < *charlie; i++) { if (i % 3 == 2) *(simca + i) = GetBlock(sizeof(int)); else *lydia++ = *charlie – i; } *(*joann)[2] = ***joann + 2; Chevril(delia); DRAW THE STATE OF MEMORY HERE } void Chevril(char **nigella) { *nigella = Concat(*nigella, "there"); } Write your answer on the next page
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有