0 votes 0 votes #include <stdio.h> int main(void) { int i = 0; char ch; while(1) { ch= *("hello world" + i); if(ch == '\0') break; putchar(ch); i++; } return 0; } What does ch= *("hello world" + i); do? Programming in C programming-in-c output programming + – Abhishek Kumar Singh asked Dec 30, 2017 • edited Dec 30, 2017 by Pragy Agarwal Abhishek Kumar Singh 558 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Ashwin Kulkarni commented Dec 30, 2017 i edited by Pragy Agarwal Dec 30, 2017 reply Follow Share *("hello world") means it is pointing to first char of "hello world" What I mean to say, let char p[] = "hello world", then *p menas we are pointing to first char of hello world. Same thing is applied here, instead of writing *(p+i), they wrote directly *("hello world" + i) So, ch = *("hello world" + 0) => ch ='h' ch = *("hello world" + 1) => ch = 'e' and so on... It will print the whole string hello world. 4 votes 4 votes gauravkc commented Dec 30, 2017 reply Follow Share Is the string "hello world" automatically stored temporarily somewhere by the compiler every-time that statement is executed? Coz the terminating condition is \0. How does compiler know \0 is there after "hello world"? \0 is added when some char array is storing it. But this is not the case here. 0 votes 0 votes joshi_nitish commented Dec 30, 2017 reply Follow Share hii @gauravkc How does compiler know \0 is there after "hello world"? \0 is added when some char array is storing it. the bolded part you said is not correct, string written inside double inverted commas(" ") are known to compiler as a string constant, and has an implicit termination with '\0'. for eg: at compile time when compiler sees "hello", it will mark it as a string constant and provide one implicit pointer 'p' pointing to it. now whenever you will write/refer "hello", you will be actually accessing 'p' 0 votes 0 votes gauravkc commented Dec 30, 2017 reply Follow Share okk.. Thanks :) 0 votes 0 votes Please log in or register to add a comment.