小编Tom*_*lan的帖子

C中的棘手段错误

我正在尝试为我的大学任务运行一个C项目,并且我在以下代码段中的"while(current-> next!= NULL){"行中遇到了一个seg错误:

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;
    }
}
Run Code Online (Sandbox Code Playgroud)

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) …
Run Code Online (Sandbox Code Playgroud)

c gdb pointers segmentation-fault fault

3
推荐指数
1
解决办法
124
查看次数

标签 统计

c ×1

fault ×1

gdb ×1

pointers ×1

segmentation-fault ×1