我不明白为什么将“root”分配给等于“trieu”会是一个不兼容的指针:/
#include <stdio.h>
#include <stdlib.h>
struct uniform {
char size;
int number;
struct uniform *ext;
};
struct uniform *trieu;
struct unifrom *root;
int main(void) {
trieu = malloc(sizeof(struct uniform));
root = trieu;
...
trieu = root;
当我用 gcc 编译它时,它给我:
program.c: In function ‘main’:
program.c:15:7: warning: assignment from incompatible pointer type
root = trieu;
^
program.c:57:8: warning: assignment from incompatible pointer type
trieu = root;
它之前在我制作的另一个程序中有效:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct ll {
char store;
struct ll *ext;
};
struct ll *trieu;
struct ll *root;
int main(int argc, char* argv[]) {
trieu = malloc(sizeof(struct ll));
root = trieu;
...
最佳答案
你打错了。使用 struct uniform *root;
而不是 struct unifrom *root;
。
关于c - 链接列表不兼容的指针类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34100717/