Why is the output only world | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
1st Mar 2019, 3:19 PM
Sukanya
Sukanya - avatar
4 Answers
+ 10
Print the string "Hello world" starting from 6th character ↓ index |0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5 char |H|e| l | l|o| |w|o|r| l|d|
1st Mar 2019, 4:55 PM
Ipang
+ 4
printf(6+"Hello world"); Is the same as: char* p = "Hello world"; printf( *(p+6)); You are giving printf the pointer to the beginning of the string to be displayed...
1st Mar 2019, 4:59 PM
unChabon
unChabon - avatar
+ 3
I'm not sure but i think it prints a substring starting from the 6th index(5th in C). So it prints ' world'
1st Mar 2019, 4:25 PM
Ore
Ore - avatar
0
But I want to know why ?
1st Mar 2019, 4:28 PM
Sukanya
Sukanya - avatar