char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
argv is a array of pointers.===> let this array stored at address 1000.
"ab" ----- string constant, stored at Read-only location ===> assume base address of that string is 100
"cd" ----- string constant, stored at Read-only location ===> assume base address of that string is 200
"ef" ----- string constant, stored at Read-only location ===> assume base address of that string is 300
"gh" ----- string constant, stored at Read-only location ===> assume base address of that string is 400
"ij" ----- string constant, stored at Read-only location ===> assume base address of that string is 500
"kl" ----- string constant, stored at Read-only location ===> assume base address of that string is 600
∴ the pointer at 0th location of argv points to the "ab" ===> argv[0]= 100
the pointer at 1st location of argv points to the "cd" ===> argv[1]= 200
the pointer at 2nd location of argv points to the "ef" ===> argv[2]= 300
the pointer at 3rd location of argv points to the "gh" ===> argv[3]= 400
the pointer at 4th location of argv points to the "ij" ===> argv[4]= 500
the pointer at 5th location of argv points to the "kl" ===> argv[5]= 600
void f(char **p) --- p is a pointer tot pointer to char ===> p gets the base address of argv = 1000
{
char *t; --- t is pointer to char
t = (p += sizeof(int))[-1]; ===> t = ( ( p + = sizeof(int) ) [ -1 ] ) ; ===> t = ( ( p = (p+ sizeof(int) ) ) [ -1 ] )
printf("%s\n", t);
}
p -- is a ponter to the array argv,
p+0 points addr of 0th index of that array,
p+1 points 1 addr of 1st index of that array,....
p+4 points to addr of 4th index of that array,
p+5 points to addr of 5th index of that array.
p = (p+ sizeof(int) ) ====> assume size of int =4 Bytes ==> p=p+4 ===> addr of 4th index of that array,
now p point at addr of 4th index of argv ===> p[0] = element of 4th index of argv , element of p[1] = element of 5th index of argv , ... p[-1]= element of 3rd index of argv
p[-1] = element of 3rd index of that array ==> addr. 400
t= 3rd index of that array = 400 ===> addr. 400 converted as character pointer.
printf("%s\n", t); ==> printing the string upto null character enters which is pointed by t ===> o/p:- gh