我正在尝试从文件布局一个字符指针数组。这是我的尝试:
char c; //in_file is a FILE object
char** mazestring = malloc(sizeof(char*));
while((c = fgetc(in_file)) != EOF) {
mazestring = realloc(mazestring,sizeof(char*)+sizeof(mazestring));
char *cp = malloc(sizeof(char*));
*cp = c;
}
当我写这段代码时,我不确定如此原谅nooby代码。每当我试图跑步时,我都会遇到段故障。