This code in 2nd line pointer access the char and + 5 . But how it's show output learn. Plz explain | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

This code in 2nd line pointer access the char and + 5 . But how it's show output learn. Plz explain

Char *ptr= "solo learn"; Printf(ptr +5);

23rd Aug 2020, 5:43 AM
Suparna Podder
Suparna Podder - avatar
3 Answers
+ 1
🔽<ptr> 🔽<ptr> + 5 —————————————————— | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | | S | O | L | O | | L | E | A | R | N | —————————————————— Pointer <ptr> points to the first character of string. Add 5 to <ptr>, then it points to address of the sixth character (index 5). From this point on, the characters will be printed until string terminator is found.
23rd Aug 2020, 7:59 AM
Ipang
+ 1
Thank you Ipang . Got it.
23rd Aug 2020, 8:51 AM
Suparna Podder
Suparna Podder - avatar
0
No problem Suparna Podder 👌
23rd Aug 2020, 8:52 AM
Ipang