Author Options:

Why is my C++ program detected as a virus? Answered

I just started learning C++ about 3 days ago (Using thenewboston's YouTube channel) and I am on lesson 13. I am a bit confused about lesson 13 but using my prior knowledge of C++ I have created my own calculator program to add, subtract, multiply, and divide. But when I try to upload it to mediafire.com it says that a virus has been detected. Since I can't upload a file you can't really see the program. My avast anti virus detected it as a suspicious program but confirmed it had no virus. if you want to take a look at the coding I made, here it is:

#include <iostream>
using namespace std;

int main()
    int choice;
    cout << "By: knexpert1700 \n";
    cout << "Welcome to my first calculator! Use the number protocol to choose your function \n";
    cout << "Would you like to add(1), subtract(2), multiply(3), or divide(4)? \n";
    cin >> choice;
    if(choice == 1){
        int a;
        int b;
        cout << "Please input your first addend \n";
        cin >> a;
        cout << "Please input your second addend \n";
        cin >> b;
        int c = a + b;
        cout << c << " is your sum \n";
    if(choice == 2){
        int d;
        int e;
        cout << "Please input your minuend \n";
        cin >> d;
        cout << "Please input your subtrahend \n";
        cin >> e;
        int f = d - e;
        cout << f << " is your difference \n";
    if(choice == 3){
        int g;
        int h;
        cout << "Please input your multiplicand \n";
        cin >> g;
        cout << "Please input your multiplier \n";
        cin >> h;
        int i = g * h;
        cout << i << " is your product \n";
    if(choice == 4){
        int j;
        int k;
        cout << "Please input your dividend \n";
        cin >> j;
        cout << "Please input your divisor \n";
        cin >> k;
        int l = j / k;
        int m = j % k;
        cout << l << " with a remainder of " << m << " is your quotient \n";
    if(choice > 4){
        cout << "Woops, you chose something other than 1, 2, 3, or 4. :( \n";
    int stall;
    cout << "Thank you for using my first calculator! :) \n";
    cin >> stall;

knexpert1700 is my YouTube channel if you are wondering. So what is the problem? Do I need to add #include <string> or something? Please reply back :)
(I used Code::Blocks to write this program too)

5 Replies

g-oneBest Answer (author)2013-05-04

Your code isn't malicious of course. There are anti virus applications like Avast that detect almost each own program as suspicious or virus. I have the same problems. Including more header files dosn't help because the compilers code optimizing will manage to ignore unused code. Possible workarounds:
- Exclude your application from scanning.
- Use a different compiler (e.g. Microsoft Visual Studio)
- Sometimes it helps to append extended properties to your executable. Attach a resource file to you project. Example:


#include <windows.h>


  FILEVERSION      1,0,0,0
#ifdef _DEBUG
  FILEFLAGS        0x0L  // final version
  FILESUBTYPE      VFT2_UNKNOWN // not used
  BLOCK "StringFileInfo"
    BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
      VALUE "Build",            "May 2013\0"
      VALUE "Comments",         "Basic Calculator\0"
      VALUE "Developer",        "knexpert1700\0"
      VALUE "FileDescription",  "Basic Calculator\0"
      VALUE "FileVersion",      "\0"
      VALUE "InternalName",     "calculator\0"
      VALUE "LegalCopyright",   "GPLv3 (C) 2013 knexpert1700\0"
      VALUE "OriginalFilename", "calculator.exe\0"
      VALUE "ProductName",      "calculator\0"
      VALUE "ProductVersion",   "\0"
    } // BLOCK "040904E4"
  } // BLOCK "StringFileInfo"
  BLOCK "VarFileInfo"
    VALUE "Translation", 0x409, 1252 // 1252 = 0x04E4
  } // BLOCK "VarFileInfo"

Select as Best AnswerUndo Best Answer

knexpert1700 (author)g-one2013-05-04

How would I add the properties in? I am new with this and don't really know much functions up to the basics of things such as strings, integers, classes, etc. When I add this to the program code after or before the actual "meat and potatoes" of the program I get an error for properties.rc. Do I need to make a class to retrieve rc from the properties?

Select as Best AnswerUndo Best Answer

g-one (author)knexpert17002013-05-04

You need the .rc file attached to your project.

With Code::Blocks as follows:

- Click on menu "Project" -> "Add files ..."
- A dialog window opens (if necessary navigate to the project folder).
- Right click into the window and create a new text file.
- Change name and extension to "properties.rc". Confirm warnings with "Yes".
- Double click onto the new "properties.rc" file.
- Confirm that the file belongs to the targets "Debug" and "Release".
- Now you'll see a new folder in the project explorer view. Expand it and double click "properties.rc".
- Another dialog pops up. Select "Open it inside the Code::Blocks editor" and confirm with "OK".
-Copy/Paste the code of my 1st reply into the opened file and compile.

Hope that helps.

Select as Best AnswerUndo Best Answer

knexpert1700 (author)g-one2013-05-04

Thank you! The properties file didn't have any error and I checked and did as it said. And now mediafire will let me upload it! :) Thanx

Select as Best AnswerUndo Best Answer

g-one (author)knexpert17002013-05-04

That's good news. You're welcome.

Select as Best AnswerUndo Best Answer