Given the following program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char s[50];
char *x, *y;
strcpy(s, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
x = s + 2;
y = s + 5;
strcpy(x, "01234567");
printf("%s\n", s);
strcat(y, "abcfe");
printf("%s\n", x);
printf("%s\n", x+15);
}
Question 1: What is the first line of ouput of this program?
ABCDEFGHIJKLMNOPQRSTUVWXYZ* ^ ^ ^ k | | s x yAfter the strcpy(), the bytes become:
AB01234567*LMNOPQRSTUVWXYZ* ^ ^ ^ | | | s x ySo the first line of output is: "AB01234567".
Question 2: What is the second line of ouput of this program?
AB01234567abcde*QRSTUVWXYZ* ^ ^ ^ | | | s x ySo the second line is the string that starts with x: "01234567abcde".
Question 3: What is the third line of ouput of this program?
AB01234567abcde*QRSTUVWXYZ* ^ ^ ^ ^ | | | | s x y x+15The last line of ouput is the string starting with "R": "RSTUVWXYZ".
PDF Download, 2022 Class Stats, 2023 Class Stats, 2024 Class Stats