C | Advanced Pointer | Question 7
Assume that the size of int is 4.
#include <stdio.h> void f(char**); int main() { char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" }; f(argv); return 0; } void f(char **p) { char *t; t = (p += sizeof(int))[-1]; printf("%s\n", t); } |
chevron_right
filter_none
(A) ab
(B) cd
(C) ef
(D) gh
Answer: (D)
Explanation: The expression (p += sizeof(int))[-1] can be written as (p += 4)[-1] which can be written as (p = p+4)[-] which returns address p+3 which is address of fourth element in argv[].
Quiz of this Question
Recommended Posts:
- C | Advanced Pointer | Question 3
- C | Advanced Pointer | Question 4
- C | Advanced Pointer | Question 5
- C | Advanced Pointer | Question 2
- C | Advanced Pointer | Question 9
- C | Advanced Pointer | Question 10
- C | Advanced Pointer | Question 1
- C | Advanced Pointer | Question 8
- Double Pointer (Pointer to Pointer) in C
- C++ | this pointer | Question 1
- C++ | this pointer | Question 2
- C++ | this pointer | Question 3
- C++ | this pointer | Question 5
- C++ | this pointer | Question 4
- What is a Pointer to a Null pointer



