what is difference between ++(*p) and (*p)++
Answer Posted / vint
++(*p) (or) ++*p -> Pre-increment the Value
(*p)++ -> Post-increment the value
*++p -> Increment the Position and then obtain the Value
*p++ (or) *(p++) -> Obtain the Value and then increment the Position
Example:
#include<stdio.h>
void main()
{
char str[10] = "Helyo";
char *p = str;
printf("%c
",++(*p)); // Pre-Increment the Value -> I
printf("%c
",++*p); // Pre-Increment the value -> J
printf("%c
",(*p)++); // Post-Increment the value -> J and increment to K
printf("%c
",*p++); // Post-Increment the position -> K and move to next position i.e. e
printf("%c
",*(p++)); // Post-Increment the position -> e and move to next position i.e. l
printf("%c
",*++p); // Pre-Increment the position and obtain value -> y
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are the different types of endless loops?
Can you explain the four storage classes in C?
What does %p mean?
What is class and object in c?
What is the difference between ++a and a++?
What is function what are the types of function?
What is the difference between exit() and _exit() function?
Why isnt there a numbered, multi-level break statement to break out
what are enumerations in C
what is the significance of static storage class specifier?
Why do we use stdio h and conio h?
Why do we use static in c?
What is scope rule of function in c?
Are pointers integers in c?
How do you construct an increment statement or decrement statement in C?