I have this simple program:
#include
struct S
{
int i;
};
void swap(struct S *a, struct S *b)
{
struct S temp;
temp = *a /*
Some good answers above, but I will elaborate.
temp = *a *a = *b;
This is actually a case of x = y = z;
where both x
and y
are assigned the value of z
.
What you are saying is the contents of address (a times a) become equal to the contents of b, as does temp
.
In short, *a *a =
is a valid statement. As previously pointed out, the first *
dereferences a pointer, while the second multiplies two values.