407 views

1 Answer

0 votes
0 votes
The output should be 6.

There needs to be a correction on line 5, it should be -   char *p2=p1;

Now, p1 will be incremented till the end of str. So in the end, p1 will be 6.

And there will be no change in p2. So p2=0;

Hence, it will return    p1-p2=6-0=6

Related questions

3 votes
3 votes
1 answer
1
Storm_907 asked Apr 16, 2023
461 views
Please explain this question void main() { int a =300; char *ptr = (char*) &a ; ptr++; *ptr=2; printf("%d" , a); }
4 votes
4 votes
4 answers
3
Manoj Kumar Pandey asked May 22, 2019
819 views
https://gateoverflow.in/?qa=blob&qa_blobid=14433986388826671915int main() { int a = 10; int *b = &a; scanf("%d",b); printf("%d",a+50); }What will be the Output of the fol...