如何修复 c 中的 scanf_s 函数?

How to fix scanf_s functions in c?

我正在尝试制作一个 "tik-tak-toe" 程序,我试图让它重复,所以我使用了 while 循环。我要求用户键入 1 表示是,键入 2 表示否。之后我有一个 scanf_s 声明。 出于某种原因,visual studios 2015 在我输入“是”并按 enter 时向我发出警告:

"Unhandled exception at 0x5D14B5F2 (ucrtbased.dll) in tick-tack-toe.exe: 0xC0000005: Access violation writing location 0x00000001." This warning does not show up when I pressed 2 to for no.

我用调试器找出问题所在,发现是scanf_s语句。 我试图使它只是一个常规的 scanf 语句,但是当我 运行 时,代码显示代码失败并且错误是

"'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." I've went all over the internet and tried everything I found but nothing worked. :(

int repeat = 1;
while(repeat == 1){
    printf("do you want to play again \n 1.yes \n 2.no \n");
    scanf_s("%d", repeat);
}

我希望我的代码在我按 1 时返回到开头,但它却出错了。

请仔细阅读这些函数的原型,具体看如何传递参数:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/scanf-s-scanf-s-l-wscanf-s-wscanf-s-l?view=vs-2019

提示:您通过 'repeat' 错误的方式。

另请注意:

"Unhandled exception at 0x5D14B5F2

这不是警告,更像是程序崩溃/致命错误。