The c declarations and need to solve showing values int x = 9, y = 3, z = 5, *pi
ID: 3794130 • Letter: T
Question
The c declarations and need to solve showing values int x = 9, y = 3, z = 5, *pi, *pi2; char c = 'R', d = 'D', *pc; and assuming x, y, z, pi, c, d, and pc are stored in contiguous memory locations, what are the results of executing the following code fragments (i.e., what are the contents of x, y, z, pi, pi2 c, d, and pc after the fragments execute)? Only show values for those variables that were changed by execution. pi = &y; *pi = *(pi - 1) + y; b. pc = &c; *pc = *pc + 1; pi2 = &y; Pi = (-- pi2) + 2; *(pi --) = 11;Explanation / Answer
i ll provide the only c answer and i compile it n linux based online compiler in c language
the output of pi2=&y; =holding the value of y i.e.3.
now after calling pi=(--pi2)+2; it still hold the value but changed the address of pi2 where it hold the value.
now when we calling *(pi--)=11;
it show the output segmentation fault (core dumped).
it means when a process attempts to access memory in a way that the operating system and processor cannot or will not allow. The most common cause is reading from or writing to memory that the process is not authorized to so access. For example, processes do not have access to the page of memory beginning at 0x0 and thus dereferencing the NULL pointer results in a segmentation fault.
i hope it will help you...if not please feel free to again asked the answer.
thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.