在C++中添加指针的位置

Now*_*ayz 0 c++ pointers

我有int foo,其中包含一个整数的地址.如何在一行中添加foo指向的整数?

解:

(*(int *)foo)+=1
Run Code Online (Sandbox Code Playgroud)

这就是我处理它的方式.

ssu*_*ube 6

要添加指针指向的值:

int * pointer;
int value;
(*pointer) += value; // parans for clarity, not necessarily needed
Run Code Online (Sandbox Code Playgroud)