difference between i++* and *++i
Answers were Sorted based on User's Feedback
Answer / gv_shreenivas
The postfix ++ and -- operators essentially have higher
precedence than the prefix unary operators. Therefore, *i++
is equivalent to *(i++); it increments i, and returns the
value which i pointed to before i was incremented. To
increment the value pointed to by i, use (*i)++ (or perhaps
++*i, if the evaluation order of the side effect doesn't
matter).
Ref:comp.lang.c FAQ list ยท Question 4.3
| Is This Answer Correct ? | 7 Yes | 4 No |
Answer / yathish m yadav
*++i
assuming i is declared as pointer
i will be first incremented to point to next location to
which it is pointing. then, the content of location to
which i is newly pointing will be assigned if any variable
is used like: a=*++i;
here since it is not assigned to any variable it will be
dicard.
i++*
if the statement is int a=i++*;
then i is incremented to point to next location of its type
then the content of that location is being copied to a
using *.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / vignesh1988i
i++* wont work .... as for as i know.... it's meaningless
comin to *++i, i is a pointer holding an address so here ++
and * holds the same priority so we ll go for associativity
of these operators. it's RIGHT to LEFT.
so , address in 'i' will get incremented and then if that
address points to some value means it will print that value
or else it will have garbage value
thank u
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / rukmanee
In case of i++, it'll first assign the value of i and then
increment it's value by one. But in case of ++i, it 'll
first increment the value of i by 1 and then assign the new
value of i.This is the difference between i++ and ++i.
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / khaja
it wont work bcoz its meaning less
bcoz i++* is not an increment operator(post increment)
*++i is to not a pre increment operator...
| Is This Answer Correct ? | 1 Yes | 3 No |
Can you write a programmer for FACTORIAL using recursion?
what is the difference between embedded c and turbo c ?
int main() { int i=1; switch(i) { case '1': printf("hello"); break; case 1: printf("Hi"); break; case 49: printf("Good Morning"); break; } return 0; }
what is self refrential structure
How are Structure passing and returning implemented by the complier?
Where define directive used?
Explain how do you print only part of a string?
I have one doubt. What does below statement mean? #define sizeof(operator) where operator can be int or float etc. Does this statement meaningful and where it can be used?
what will be the output for the following main() { printf("hi" "hello"); }
What are global variables?
What are comments and how do you insert it in a C program?
Can you please explain the scope of static variables?