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 is the ANSI C Standard?
What is the difference between int main and void main in c?
What are extern variables in c?
Mention four important string handling functions in c languages .
What are local static variables?
main() { printf("hello"); fork(); }
what are bit fields? What is the use of bit fields in a structure declaration?
Is return a keyword in c?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
What is the importance of c in your views?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
Can the sizeof operator be used to tell the size of an array passed to a function?
What oops means?
what are enumerations in C
Is it valid to address one element beyond the end of an array?