C:修改通过typedef传递的int指针的最佳方法是什么?

use*_*636 1 c pointers typedef

我有一个typedef int my_type,我有一个看起来像的函数

void my_func (my_type* x);
Run Code Online (Sandbox Code Playgroud)

我应该如何使用此函数使用最佳实践修改x?

cla*_*laf 10

您可以在函数中使用解除引用运算符'*':

void my_func (my_type* x)
{
  assert(x); // To protect from NULL pointer as mentioned in com.

  *x = 5; //for example
}
Run Code Online (Sandbox Code Playgroud)