Open In App

C | Pointer Basics | Question 17

Like Article
Like
Save Article
Save
Share
Report issue
Report




#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);
}


(A) ab
(B) cd
(C) ef
(D) gh


Answer: (D)

Explanation: argv is a pointer array of type char. So it contains character pointers like ab, cd, etc. f(argv) in this call we give address of the first char pointer ab. in function f , t = ( argv[0] += 4 (its size of int) [-1] . after this evaluation t points to ij but after [-1] t will point to gh.

Quiz of this Question


Last Updated : 12 Nov, 2020
Like Article
Save Article
Share your thoughts in the comments
Similar Reads