嘿,我这里有一大段代码,应该将文件读入链表:
void loadFile() {
Event *event;
FILE *file;
int nRead = 7;
char filename[30];
LinkedList *list;
list = (LinkedList*)malloc(sizeof(LinkedList));
event = (Event*)malloc(sizeof(Event));
printf("Please input filename\n");
scanf("%s", filename);
file = fopen(filename, "r");
nRead = fscanf(file, "%d-%d-%d %d:%d %d %s", &(list->head->event->date->year), &(list->head->event->date->month), &(list->head->event->date->day), &(list->head->event->time->hours), &(list->head->event->time->minutes), &(list->head->event->duration), event->name);
if(nRead != 7) {
printf("Error in reading file.\n");
}
fclose(file);
}
在这里我有一些我的主要部分
int main(int argc, char **argv) {
Window *window;
Event *event;
FILE *file;
window = createWindow("Calendar");
if(argc == 2) {
file = fopen(argv[1], "r");
if(file == NULL) {
printf("Could not open file.\n");
} else {
printf("File opened successfully!\n");
}
}
else {
addButton(window, "Load a calendar from file.", *loadFile(), &event); //ERROR HERE
}
}
这是addButton(不需要知道功能,只需要语法帮助)
void addButton(Window *window, char *label, void (*callback)(void*), void *data);
我得到错误:
assignment.c: In function ‘main’:
assignment.c:22: error: void value not ignored as it ought to be
我真的不知道为什么,我被困在这部分。我环顾四周,发现当您将具有 void 返回的函数分配给变量或其他内容时,会发生 void value not ignored 错误,但我认为我的代码中没有这样做...
任何帮助将不胜感激