尝试读取文件时的奇怪行为

strange behavior when trying to read a file

if(argc==1){    
    } else if(argc==2){
        FILE *f=fopen( argv[1],"r");

        if(!(f==NULL)){
            jogada='x';
            while(countblank(board)!=0 || (checkmoves(board,jogada)>0)){
                fscanf(f,"%d%c",&fline,&fcol_char);
                fcol=fcol_char-'A';
                fline--;

                play(board,fline,fcol,jogada);
                jogada=opcolor(jogada);
                if(fgetc(f)==EOF){
                    break;
                }
            }
            fclose(f);
            print_board(board);
        }
        else{
        printf("\nFicheiro não foi lido\n");
        }
    }

我使用 gcc,当我使用 ./othello_func jogadas.txt 时,它应该读取文件 jogadas.txt 中的剧本,其中包含类似

的内容
4C
3E

但是当我这样做时 ./othello_func jogadas.txt 它只是向我显示来自 else 的消息。

when I do ./othello_func jogadas.txt it just shows me the message from the else.

  • 程序“othello_func”和“jogadas.txt”不在同一个文件夹中。 但可能会弄错 运行 来自哪个文件夹代码。

  • 文件“jogadas.txt”无法读取 - 可能正在被其他程序(如编辑器)使用。