0

The first time I compiled and ran my program in dev console when I opened it my pc started lagging and it created a bunch of .tmp files on my desktop with names like trzFE47.tmp and my pc started lagging I had to turn off my pc I even checked the background processes with task manager for something suspicious but I found nothing so when I rebooted my pc I went to compile my .cpp program again avast gave me a warning saying suspicious item detected heres my code

#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;
}
Pang
  • 9,564
  • 146
  • 81
  • 122
Roblox Man225
  • 75
  • 1
  • 8
  • 2
    You can't call main() from within the program. UB. – doug Aug 01 '16 at 02:30
  • 1
    According to the spec you can't call main(), but in practice, at least the GCC compiler will let you do this. Having a quick look, that would like result in a lot of recursion, with associated stack usage, etc. Maybe avast picks it up as something that consumes excessive resources? Is there a log output of avast available? – roelofs Aug 01 '16 at 02:33
  • Try not to `using namespace std;` –  Aug 01 '16 at 02:49

3 Answers3

5

Avast tends to think any program it hasn't seen before is "suspicious". Usually it "scans" the program, doesn't find anything and lets you carry on executing. With most anti-virus systems it's a good idea to add the folder you compile your code in to an exclusion list.

A side not about your program, and as was pointed out, you can't call main()

Community
  • 1
  • 1
Assimilater
  • 944
  • 14
  • 33
  • i want to restart my function with out using system("start program.exe") – Roblox Man225 Aug 01 '16 at 02:36
  • 3
    I would advise writing a separate function, and having main call that function multiple times rather than try and call `main()` again – Assimilater Aug 01 '16 at 02:36
  • 2
    @RobloxMan225 That's an entirely separate question to what you are asking, and there is plenty of information on this site regarding "running a program until a user decides to quit" – Tas Aug 01 '16 at 02:36
  • I suppose it's possible Avast is noticing the program is calling main() internally aside from the regular entry path and treating that as suspicious. – doug Aug 01 '16 at 02:39
  • I've had avast stop my programs and scan them for simple "hello world" programs written in good practice. – Assimilater Aug 01 '16 at 02:41
  • thanks so much for the help now does any one know how to clear the console – Roblox Man225 Aug 01 '16 at 02:41
  • @RobloxMan225 That's a [separate question](http://stackoverflow.com/questions/6486289/how-can-i-clear-console). If you found this helpful, please mark this as answered :) – Assimilater Aug 01 '16 at 02:43
  • I think roelofs just said in a comment above that `gcc` allows you to call `main()`. –  Aug 01 '16 at 03:03
  • @VeniVidiVici gcc letting a rule slide doesn't mean it's not breaking a rule. See [this other SO answer](http://stackoverflow.com/a/2128727/310560) – Assimilater Aug 01 '16 at 03:08
0

To test that your compiled file has a virus or not Just put your compiling folder in the exceptions of your antivirus and then right-click on that .exe file and scan with your antivirus. If it reports a virus then it is sure that you file contains a virus and if not it should say no viruses or malware found. Worked For Me:)

-1

Best method which worked for me is to put the program in the "Allow" list in the antivirus's (Avast's) "Allowed & Blocked apps" menu in the settings.