Two expressions are different. Let's look at a sample code to understand the difference between the two expressions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include <stdio.h>
int main(void)
{
int aiData[5] = {100,200,300,400,500};
int *piData = aiData;
++*piData;
printf("aiData[0] = %d, aiData[1] = %d, *piData = %d", aiData[0], aiData[1], *piData);
return 0;
}
|
Output: 101,200,101
Note:
In the above example, to two operators, both of which have the same priority, have relevance from right to left. So the above expression ++ * p equivalent ++ (* p). In other words, we can say it is a pre-increment value, the output is 101,200,101.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include <stdio.h>
int main(void)
{
int aiData[5] = {100,200,30,40,50};
int *piData = aiData;
*++piData;
printf("aiData[0] = %d, aiData[1] = %d, *piData = %d", aiData[0], aiData[1], *piData);
return 0;
}
|
Output: 100,200,200
Note:
In the above example, to two operators, having a right to left both associated with the same priority. So the above expression * ++ p equivalent * (++ p). In other words, you can say it is a pre-increment address output is 100,200,200.