当我编译我的 C++ 代码时,avast 认为它是病毒

Rob*_*225 0 c++

我第一次在开发控制台中编译并运行我的程序时,当我打开它时,我的电脑开始滞后,它在我的桌面上创建了一堆 .tmp 文件,名称类似于trzFE47.tmp我的电脑开始滞后我不得不关闭我的电脑我什至检查过任务管理器的后台进程处理可疑的事情,但我什么也没发现,所以当我重新启动我的电脑时,我再次编译我的 .cpp 程序,avast 给了我一个警告,说在我的代码中检测到可疑项目

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
using namespace std;

int main() {
    int l;
    int a;
    int b;
    int c;
    Sleep(3000);

    srand(time(0));
    l = 1+rand()%6;
    a = 1+rand()%6;
    b = 1+rand()%6;
    c = 1+rand()%6;
    cout << a  << endl << b << endl << c << endl;
    if (a==b&& b==c&&c==a){
        int v;
        cout << "you win";
        cin >> v;
    }else{
        cout << "try again?";
        string z;
        cin >> z;
        if (z == "yes"){
            main();
        }
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Ass*_*ter 5

Avast 倾向于认为它以前从未见过的任何程序都是“可疑的”。通常它会“扫描”程序,找不到任何东西并让您继续执行。对于大多数防病毒系统,最好将编译代码的文件夹添加到排除列表中

与你的程序无关的一面,正如所指出的那样,你不能打电话main()

  • 我建议编写一个单独的函数,并多次调用该函数,而不是再次尝试调用 `main()` (3认同)
  • @RobloxMan225 这与您要问的问题完全不同,并且该站点上有很多关于“运行程序直到用户决定退出”的信息 (2认同)