581 views
0 votes
0 votes
Please explain solution in brief .

#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

1 Answer

0 votes
0 votes
**p contains add of "ab"

According to OperatorPrecedence

1)  sizeof(int) = 4

2)  (p +=sozeof(int))  == (p = p +4)

              and p+4 is address of "ij"

3)  (p += sizeof(int))[-1]  mean "gh"

so t = gh

Related questions

0 votes
0 votes
2 answers
1
anonymous asked May 14, 2018
512 views
What changes must be done for printing value 5. #include <stdio.h int main() { int var; /*Suppose address of var is 2000 */ void *ptr = &var; *ptr = 5; printf("var=%d and...
0 votes
0 votes
1 answer
2
Debargha Mitra Roy asked 3 days ago
47 views
#include <stdio.h int main() { int a[3] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)T...
1 votes
1 votes
2 answers
3
0 votes
0 votes
1 answer
4
ermp888 asked Jun 30, 2018
669 views
6. Would the following program compile?main( ) { int a = 10, *j; void *k; j = k = &a; j++ ; k++; printf ("\n %u %u", j, k ) ; }Please explain above program with some exam...