90: if (links->info[links->length-1].paths = malloc(connections*sizeof(char*))==NULL) {
perror("Malloc failed! Aborting execution\n"); exit(MF);}
for (j=0; j<connections; j++) {
93: if (links->info[links->length-1].paths[j] = malloc(250*sizeof(char))==NULL) {
perror("Malloc failed! Aborting execution\n"); exit(MF);}
}
,其中
Link *links;
int connections;
typedef struct{ //Info of the link
int inode; //I-node
int prime_inode; //Corresponding i-node
int connections; //Number of hard links
int next_path; //Where to put the next path
char **paths; //Paths that refer to the i-node
} Link_info;
typedef struct {
int length; //Number of links
Link_info *info; //The array of the link info
}Link;
我得到了这些警告
traverse.c:90:52: warning: assignment makes pointer from integer without a cast [enabled by default]
traverse.c:93:59: warning: assignment makes pointer from integer without a cast [enabled by default]
我想创建一个字符串数组,其中包含“连接”#个单元格,每个字符串最多包含250个字符。我想知道这有什么不对。
答案 0 :(得分:6)
links->info[links->length-1].paths = malloc(connections*sizeof(char*))==NULL
==
优先于=
。
这应该是
(links->info[links->length-1].paths = malloc(connections*sizeof(char*))) == NULL