我正在调试这段代码:
int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr, "Error: Add filepath to a chessposition");
return EXIT_FAILURE;
}
FILE* pchess_file = fopen(argv[1], "r");
if(!pchess_file){
perror("Error: File not found");
return EXIT_FAILURE;
}
CHESS_STATE chess_state;
loadBoard(&chess_state.board_state, pchess_file);
printBoard(&chess_state.board_state);
//valdiate board
}
我指定了参数“board.chess”,并且表示的文件被放置在调试文件夹中。然而,Eclipse似乎改变了目录。当照常执行时,代码可以工作。
最佳答案
解决方案是调试时Eclipse运行在“Project”目录中,而不是“Project/Debug”目录中。
将所有文件移至“Odin”文件夹中。
关于c - Eclipse 中的 GDB 调试器找不到 FILE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57240342/