Question: Consider the following C program. #include #define SIZE_S 6 #define SIZE_I 3 int main(void) { int i[SIZE_I] = {0, 1, 2}; char s[SIZE_S] = 01234

Consider the following C program.

#include

#define SIZE_S 6

#define SIZE_I 3

int main(void) { int i[SIZE_I] = {0, 1, 2};

char s[SIZE_S] = "01234" ;

printf("i = %p ", i);

printf("s = %p ", s);

scanf("%s", s);

printf("i[0] = 0x%x ", i[0]);

printf("i[1] = 0x%x ", i[1]);

printf("i[2] = 0x%x ", i[2]);

printf("s = %s ", s);

return 0;

}

Here are the printf outputs showing the addresses of the arrays in memory. The text following the two printf outputs is what is typed at the keyboard for the scanf call.

$ a.out i = 0x7ffee77b49ec

s = 0x7ffee77b49e0

LoyalStrong&True

Below are the contents of memory in hexadecimal before the input with ?? indicating an unknown value. What are the contents of memory after the input? Clearly label where s and i start on both of the memory diagrams with their associated addresses from the earlier printf output.

 Before 00 00 00 02 00 00 00 01 00 00 00 00 ?? ?? ?? ?? ?? ?? 00 34 33 32 31 30 

After

What is output by the last four printf calls after the input?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!