Question: Consider the following C program. #include int main ( void ) { int i [ 2 ] = { 2 , 4 } ; char

Consider the following C program.
#include
int main(void){
int i[2]={2,4};
char s[6]="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("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 =0x7ffdbd980ef4
s =0x7ffdbd980eec
!!Rise&ShoutBYU
Below are two tables displaying the contents of memory in hexadecimal. Each table shows memory in rows
of four bytes, with the address of the left-most byte on each row shown to the left of the row. Addresses
increase as we move to the right and down in the image. On the left is memory before the input is scanned in,
with ?? indicating an unknown value. Your tasks will include identifying where things are on the memory
table on the left and also filling in the table on the right with the contents after the input.
Before scanf After scanf
Address Bytes Address Bytes
... ec 30313233... ec
... f03400????... f0
... f402000000... f4
... f804000000... f8
1. Which locations in the memory table contain the bytes for i[0]?

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!