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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started