使用Microsoft Visual Studio 2019创建新的C++控制台应用程序。添加一个文件,将其命名为tictactoe.c。粘贴下面给出的代码-
#include <stdio.h>
int main(void)
{
int player = 0;
int winner = 0;
char board[3][3] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'} };
//The main game loop. The game continues for up to 9 turns.
for (unsigned i = 0; i < 9 && winner == 0; ++i) {
//Display the board
printf("\n");
printf(" %c | %c | %c \n", board[0][0], board[0][1], board[0][2]);
printf("-----+-----+-----\n");
printf(" %c | %c | %c\n", board[1][0], board[1][1], board[1][2]);
printf("-----+-----+-----\n");
printf(" %c | %c | %c\n", board[2][0], board[2][1], board[2][2]);
player = i % 2 + 1;
}
return 0;
}
构建它,然后运行它。由于某些原因,Windows defender认为它检测到了威胁!
发布于 2020-10-28 20:28:39
这似乎是来自Windows defender的误报。类似的问题也发生在MinGW等其他编译器上。请参考Code::Blocks MinGW Windows Defender Trojan:Win32/Fuery.C!cl中的一个这样的实例。
规避此问题的方法是在Windows控制面板的“病毒和威胁防护”页面的“允许的威胁”窗口中将您的二进制文件标记为异常。请参阅下面的屏幕截图(假设是Windows 10)。
发布于 2020-10-28 19:51:08
您的代码看起来很正常。我认为Windows Defender的问题是因为误报检测。我在我的MSVC2019上检查了一下--第二次运行的结果是一样的(第一次运行正常)。让我们在Microsoft支持论坛上问这个问题吧?
https://stackoverflow.com/questions/64572061
复制相似问题