in Programming in C
613 views
0 votes
0 votes

in Programming in C
613 views

4 Comments

yes fg should be printed

0
0

@Bhagyashree Mukherje,

it's my suggestion ( neither request nor order ),

when you dealing with variable memory addresses and pointer memory addresses, take integer size=4B and Pointer Size=2B

it will help you for more understanding

0
0
Ok.Will keep it in mind henceforth.Thanks
0
0

1 Answer

1 vote
1 vote
We're printing **++ptr+1

Adding brackets for simplicity (*(*(++ptr))+1)

ptr points to p[0]
*(++ptr) point to *p[1] which is s+1

*(s+1) points to "efg"

printf("%s","efg" + 1);
prints fg

So answer is B)

2 Comments

@vikas @bhagyasree

printf("%s","efg" + 1);

Please suggest how it prints fg.

I'm not able to understand this logic.Please help

Thanks
0
0
edited by

 Mayankprakash when we use  %s it takes the starting address  and print it till \0.

in this case let addresses be like 

e f g
100 104 108

starting address of "efg" which is 100 , starting address of  "efg" +1 means 104 so, %s will start from address 104 and print till \0

 

 

3
3