+ 7
What is happening in this code?
Output of below code is h , plz explain how ? What happens when we use operator * or & more than once in same line ? int main() { char *ptr = "helloword"; printf("%c\\n", *&*&*ptr); return 0; }
4 Answers
+ 4
Here your decleared *ptr pointer which type is char type and u storing helloworld in printf statement u use %c after that \\n Slash work as separatator so if u will write two slash it single Slash will be print then *ptr will point first char &ptr will print address then *&ptr again pointing first char then & address then * for value.
So that *&*&*ptr will point value which is first char h
So output will be
h \n
+ 5
Thank you Syrah Algena . Now I get it . The extra slash is by mistake , by the way \n is unusable there .
So, in simple (*,&) these operators cancel out effect of each other when used one after another?
+ 2
Hrutik Bhalerao yeah
+ 1
Pointr 0 +1 +2 +3 +4 +5 +6 +7 +8
Vaue. h e l l o w o r d
Pointr its a address of cell in memory
Value its a char in cell.