首页 > 解决方案 > 如何退回我的“theMove”并解决写作权问题

问题描述

我正在尝试用运动做一个棋盘,但我无法设法让 2 个棋子的坐标移动:

void saisie_deplacement(int color)
{
    char lettre[8]={'A','B','C','D','E','F','G','H'};
    deplacement theMove;

    char L,L1;
    int x,x1,y,y1;

    printf("\n\n\nType the 1st piece's Letter.\n");
    scanf(" %c", &L);

    x = L;
    x = x-'A';
    printf("\n%i\n", x);

    printf("\nType the 1st piece figure\n");
    scanf(" %i", &y);

    printf("\nType the 2nd piece letter\n");
    scanf(" %c", &L1);

    x1= L1;
    x1=x1 - 'A';
    printf("\n%i\n", x1);

    printf("\n\n\nType the 2nd piece figure\n");
    scanf(" %i", &y1);

    theMove.depart.ligne = x;
    theMove.depart.colonne = y;
    theMove.arrivee.ligne = x1;
    theMove.arrivee.colonne = y1;

}

我不知道我怎么能回来theMove

否则,CodeBlocks 会告诉我:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
ld.exe||cannot open output file C:\Users\dissi\Desktop\C\tpregled.exe Permission denied|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

然后我无法在不更改 .exe 文件名的情况下进行编译。我的程序似乎在 ntoskrnl.exe 中保持打开状态

你们知道我应该怎么做吗?:)

标签: ctypedef

解决方案


要返回theMove,请执行以下操作:

首先声明该函数将返回它:

deplacement saisie_deplacement(int color) {

void意味着它什么都不会返回,但你确实希望它返回某种类型的东西deplacement

然后在填写完所有字段后,告诉函数返回类型变量deplacement

    return theMove;
}

推荐阅读