質問

This is not logic :

int *ptr = &otherInt;

When we do that, ptr gives adress of otherInt, *ptr gives otherInt.

But we write explicitly that (*ptr) equals adress *ptr = &otherInt !

Logically, *ptr should give the adress, and ptr the otherInt.

Don't you think ?

役に立ちましたか?

解決

I think you got it all wrong. Consider this:

int *ptr;
int otherInt = 10;

ptr = &otherInt; // Notice this line.

The asterisk is a part of the declaration, not the assignment.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top