我有一个指向名为 sp 的结构的指针。
struct thestruct *sp_pointer = NULL;
sp_pointer = sp;
该结构有一个称为单位的字段。即sp->单位
如果我要做sp_ponter->units = sp_pointer->units + 100;
这会更新 sp->units 中的值吗?
最佳答案
if I were to do sp_ponter->units = sp_pointer->units + 100;
would this update the value in sp->units?
是的,会的。分配后,sp_pointer
指向与 sp
相同的内存。假设两个指针的类型相同,那么您所拥有的应该没问题。
关于c - 更新指针值会更新它指向的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36292460/