c - 如何退回我的“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 中保持打开状态
你们知道我应该怎么做吗?:)
解决方案
要返回theMove
,请执行以下操作:
首先声明该函数将返回它:
deplacement saisie_deplacement(int color) {
(void
意味着它什么都不会返回,但你确实希望它返回某种类型的东西deplacement
)
然后在填写完所有字段后,告诉函数返回类型变量deplacement
:
return theMove;
}
推荐阅读
- tinymce-4 - 如何在 Tinymce 5 中显示所有工具栏按钮?
- kubernetes - 仅检索 pod 计数而不在 kubernetes 中列出
- wpf - 使用 C++ DLL 部署 WPF 应用程序
- algorithm - 在二分查找中,为什么不先检查要查找的元素是否小于或大于数组的最小或最大索引?
- c# - 当我单击附加表单中的取消按钮时,它的行为类似于确定按钮 - 为什么?
- graphql - GraphQL Mutation 更新数据库中的字段数组
- kiwi-tcms - 无论如何使用 Python API 来获取测试运行的状态?
- c# - 使用 CSS 选择器或 Xpath 选择具有动态 ID 的单选按钮
- java - 当我不再访问文件时,为什么在 Eclipse 上出现 FileNotFoundException?
- python - 操作系统错误:[WinError 123] 文件名、目录名或卷标语法不正确