같음 모든 것은 mystruct
입니다.크기는 몇 가지 이유를 들어 1
크기 1을 얻는 이유는 무엇일까요? 감사합니다.
// fragments of my code
struct mystruct {
char *raw;
int count;
};
struct counter {
int total; // = 30
}
static struct mystruct **proc()
{
int i = 0;
gchar *key,*val;
struct mystruct **a_struct;
struct counter c;
a_struct = (struct mystruct **)malloc(sizeof(struct mystruct *)*c.total);
while (table (&iter, (gpointer) &key, (gpointer) &val)) {
a_struct[i] = (struct mystruct *)malloc(sizeof(struct mystruct));
a_struct[i]->raw = (char*)key;
a_struct[i++]->count = (int)val;
}
size_t l = sizeof(a_struct)/sizeof(struct mystruct*);
printf("%d",l); // outputs 1
}
또한 size_t에 % d 형식 지정자 대신 % zu를 사용하십시오. –
감사합니다. 문제가 해결되었습니다! – Josh