string c is:
G
|
A
|
T
|
E
|
C
|
S
|
I
|
T
|
2
|
0
|
1
|
7
|
NULL
|
100 101 102 103 104 105 106 107 108 109 110 111 112
\(\begin{matrix}p & \boxed{100} \\\ {} & 200 \end{matrix}\)
Character is of one byte and hence each character it placed at one byte of space .
char* p = c; // p is pointing to base address of c
2[p] = p[2]
ASCII value of T and I in decimal are is 84 and 73 respectively.
c+2[p] – 6[p]-1 = 100 + p[2] - p[6] – 1
= 100 + T – I – 1 = 100 + (84 - 73) – 1
= 100 + 11 – 1 = 110
Which means string starting from address 110 onwards till 111
So, (int)strlen (c+2[p] – 6[p]-1)
= (int)strlen(“17”)
The output of the program is 2.