+ 5
Some one explain this code plz,^^
pointers and "&" https://code.sololearn.com/cg72o4hzX0gC/?ref=app
23 Respuestas
+ 9
yes you are right KrOW as I set a code if you try it in turbo cpp4 u will get answer as 1 0 1 1 1 but in gcc and in our play ground will get answer as 1 1 1 1 1
+ 6
problems like this code the main thing is priority and associativity matters as Deepak sir said I have one more code which suits the same problem
https://code.sololearn.com/cu7gKp7uNqOX/?ref=app
+ 4
++i is pre increment and it gets executed first.. which makes i as 2.
I** is post increment and it has second priority after pre increment.. i and *p is same... so (*p)++ is 2 only and then value updates to 3. so output is 322
+ 4
Anas Sanba int *p is a pointer variable.
Its assigning the value of i variables memory address -
int *p = &i;
Revise the tutorial.
Or, go to
https://youtube.com/user/thenewboston
Search for pointers.
+ 4
Guys maybe i am not been clear.... Order evalution of expression passed like function parameters ARE NOT DEFINED by standards then ANY compiler can evalutate they in ANY order.... Here for more simple words https://www.geeksforgeeks.org/g-fact-20/
and here from official source https://en.cppreference.com/w/c/language/eval_order
+ 3
I want make note that evalutation order with side-effect expressions its not specified in standards (or they have undefined bahviour eg. implementation dependents)
https://www.geeksforgeeks.org/g-fact-20/
In practice dont assume that an parameter its evalutated before another
+ 2
Anas Sanba what shady business is going on! Why is the output messed up. I don't get it.
Anyway:
Pointers points to the memory address of a variable.
The & operator is used to indicate the memory.
+ 2
Deepak Gautam shouldn't that be 1? for the first one.
+ 2
KrOW ,Thank you. I was really confused bout that.
+ 2
thank you so much guys i get it now 😙
+ 2
as p is pointing to i, *p is nothing but value pointed by i
+ 2
Deepak Gautam
+ 2
it's juste one?
+ 2
ah!! there is exchange between p and i ?
+ 1
explain me int *p =&i;?
+ 1
how *p=3?
0
Ketan so *p =i=1?
0
I did know about precedence but this worked very weirdly.
I am but confused.
0
As krow mentioned it's behavior isn't specified in the documentation. I thought arithmetic operations in printf didn't have effect on the variables but in this case it clearly does.
0
deepak why value of i become 3?