我正在尝试打印由指针指向的指针指向的值。
我有两个结构
typedef struct s_thread_police
{
l_hash *lhash;
// other stuff for thread purpose
} thread_police_arg;
typedef struct s_l_hash
{
struct s_l_hash* next;
char* hash;
} *l_hash;
如何打印我指向的struct的哈希?
police_arg.lhash = &lhash;
printf("%s\n", *(police_arg.lhash)->hash);
编译器告诉我“错误:请求成员'哈希'的东西不是结构或联合”
我尝试了其他方式,但他们都没有为你的帮助工作
你要这个:
printf("%s\n", (*police_arg.lhash)->hash);
*police_arg.lhash
给你一个l_hash
,这是一个指向s_l_hash
的指针,然后你取消引用hash
。