how to set pointer to a memory to NULL using memset?

后端 未结 9 860
执笔经年
执笔经年 2020-12-11 08:35

I have a structure

typedef struct my_s {

   int x;
   ...
} my_T;

my_t * p_my_t;

I want to set the address of p_my_t to

9条回答
  •  失恋的感觉
    2020-12-11 09:15

    I think maybe you want

    extern void set_t_pointer_to_null(my_T *pp);
    

    and call

    set_t_pointer_to_null(&p_my_t);
    

    where

    void set_t_pointer_to_null(my_T *pp) { *pp = NULL; }
    

    I'm not sure it's worth defining a function to do this, but I think this answers the question you're trying to ask.

提交回复
热议问题