Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Testing out of bound values Modify the example addressArithmetic3.c by creating an array of 5 values before numbers and a second array after numbers. Fill

Testing out of bound values Modify the example addressArithmetic3.c by creating an array of 5 values before numbers and a second array after numbers. Fill each with distinct values. Use #include to include the declaration of your datatype from Part I. Display values from numbers using subscripts from 6 to 9. From which array (if either) do these values come from? b. Display values from numbers using subscripts from -1 to -5. From which array (if either) do these values come from? c. Modify your listing so that instead of using numbers[i] you use the pointer dereferencing notation *(numbers+i) to refer to elements of the array. Is there any change in output? d. Add the following declarations to your code after the 3 arrays: char *newString1=(char *)alloca(100); char newString2[100]; struct yourDataType *item1=(struct yourDataType *) calloc(sizeof (struct yourDataType),5); Print out the value of the pointers newString1 and newString2 Where in memory are they in relation to your arrays? Are they in the stack or the heap? e. Add values from -3 to +3 to both newString1 and newString2 and print out the values. Explain the results in terms of address arithmetic. f. Print out the values item1 and &item1. Where are they in memory in relationship to your arrays? Explain the results in terms of address arithmetic? g. Set up your program so that it uses both the function and the script mtrace to trace memory allocation. Describe what you did. What does the mtrace shell command tell you about the allocation and freeing of memory in the program? (2 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago