[英]Struct and pointer
我正在尝试打印由指针指向的值,该指针本身也由指针指向。
我有2个结构
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;
如何打印指向的结构的哈希值?
police_arg.lhash = &lhash;
printf("%s\n", *(police_arg.lhash)->hash);
编译器告诉我“错误:在非结构或联合中请求成员'哈希'”
我尝试了其他方法,但没有一个在Thx的帮助下
你要这个:
printf("%s\n", (*police_arg.lhash)->hash);
*police_arg.lhash
给您一个l_hash
,它是指向s_l_hash
的指针,然后您可以将其取消引用以获取hash
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.