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


Please Help Members By Posting Answers For Below Questions

What is the ANSI C Standard?

782


What is the difference between int main and void main in c?

596


What are extern variables in c?

551


Mention four important string handling functions in c languages .

634


What are local static variables?

622






main() { printf("hello"); fork(); }

699


what are bit fields? What is the use of bit fields in a structure declaration?

1502


Is return a keyword in c?

602


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

634


What is the importance of c in your views?

599


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

2803


Can the sizeof operator be used to tell the size of an array passed to a function?

622


What oops means?

588


what are enumerations in C

726


Is it valid to address one element beyond the end of an array?

677