(a) Does the
==operator correctly test for equality between strings? (b) Since arrays ofcharsandchar*pointers act similarly, can we test equality by using a line likeif(*C == *D)? Test in CodeAnywhere/Repl to verify your answers.
Make a
compare.cfile in your repository and complete acompare()function to evaluate whether two strings are equal. To do this, you will need to step through each string comparing characters, until you reach the string termination character. Be sure your code works for all the tested cases above, plus any others that might be important.
Implement the above in
arrayExample.c
Describe where in the memory diagrams the strings will be stored (you may need to look back to a prior module). Why can't the string data be stored on the stack?
Implement the above in
arrayExample2.c
Implement the above in
arrayExample3.c, completing the code inmain(), and including the struct definition and theprint()method.
Add code to your
arrayExample3.cto print the start address of each heap block, and include that in a memory diagram below. You do not need to list addresses on the stack or globals area.
Stack:
| Name | Contents |
|---|---|
Globals:
| Name | Contents |
|---|---|
Heap:
| Address | Contents |
|---|---|
Implement the above in
linkedlistExample.c, including a completeprintList()function, and fill in a complete memory diagram right after the three nodes are to the list (only include heap addresses - use the debugger to find them).
Stack:
| Name | Contents |
|---|---|
Globals:
| Name | Contents |
|---|---|
Heap:
| Address | Contents |
|---|---|
Implement the above in
linkedlistExample2.c, completing the required methods. For the moment, thecopy()method can remain not implemented.
Implement the
copy()method, ensuring that a deep copy is made, so that every person struct is duplicated. Un-comment the block comments inmain(). Add all this code tolinkedlistExample2.c.
Implement the needed code in various methods in
linkedlistTable.cto make this idea work. You have seen this data structure before. What is it called? Draw a memory diagram after the first three insertions. You can either use a markdown table, or draw on paper and add a photo to your README file.