[英]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.