2013-08-24 53 views
0

這是我比較功能......正確使用scandir()進行排序?

int nameSort(const struct dirent** file1, const struct dirent** file2){ 

    char* a = *file1 -> d_name; 
    char* b = *file2 -> d_name; 
    //printf("comparing %s  AND %s\n", a, b); 
    return strcasecmp(a,b); 
} 

上午錯誤:沒有東西結構或聯合 請求成員「d_name」你是怎麼在這裏?

回答

1

通過指針操作->成員選擇的Precedence超過*防守運營商更高,因此

*file1->d_name; 

應該是:

(*file1)-> d_name; 
+0

試試看它應該工作 –

相關問題