構造体へのポインタである「ハッシュ」があります。ポインターでもあるメンバー統計を取得しようとしています。私はただできると思っていました: hash->stats しかし、それは参照統計構造体を返すようです。「->」は左側の変数を逆参照するだけですか?
struct statistics {
unsigned long long count;
...
};
struct hashtable {
GHashTable * singleton; //Single Hash Table to Store Addresses
struct statistics *stats; //Statistics Table
};
GHashTable *ghash = g_hash_table_new(NULL, NULL);
struct hashtable *hash = (struct hashtable *) malloc(sizeof(struct hashtable));
//Works but why isn't hash->stats ok?
memset(&hash->stats, 0, sizeof(struct statistics));
この時点でこれを試してみると:
struct statistics *st = hash->stats;
私は得る:
incompatible types when initializing type 'struct statistics *' using type 'struct
statistics'