【发布时间】:2014-12-20 22:51:19
【问题描述】:
我正在尝试为我的大学作业运行一个 C 项目,但在以下代码段中的“while (current->next != NULL) {”行中遇到了段错误:
FILE* f = fileOpen("test.txt");
if (f != NULL){
functionList = fileReadToMemory(f, &graphParams);//functionList is a pointer to the first value of the linked list it creates
current = functionList;
while (current->next != NULL) {
printf("%d %d %d %s", current->red, current->green, current->blue, current->expression);//Prints value of linked list
current = current -> next;
}
}
gdb给我的错误如下:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x000000000000003a
0x0000000100000b30 in main () at main.c:23
23 while (current->next != NULL) {
我做错了什么?
提前致谢!
【问题讨论】:
标签: c pointers segmentation-fault gdb fault