#include<stdio.h>
#include<conio.h>
union abc
{
int a;
int x;
float g;
};
struct pqr
{
int a;
int x;
float g;
} ;
void main()
{
union abc b;
struct pqr c;
clrscr();
b.a=10;
textbackground(2);
textcolor(6);
cprintf(" A = %d",b.a);
printf("\nUnion = %d",sizeof(b));
printf("\nStructure = %d",sizeof(c));
getch();
}
我已将此程序保存为 virus.cpp。我正在使用 Turbo C 编译器来编译这个程序并从 Turbo C (Ctrl + F9) 运行。
我使用的是 Windows 7,并且我已经安装了 Avira AntiVir 病毒系统。
当我试图运行上面的程序时,它会创建一个蠕虫(DOS/Candy)。我相信程序没有错。
现在这里有一些特别的东西。执行相同的程序,但有以下不同。这里唯一的区别是之间的空间\n
:
#include<stdio.h>
#include<conio.h>
union abc
{
int a;
int x;
float g;
};
struct pqr
{
int a;
int x;
float g;
} ;
void main()
{
union abc b;
struct pqr c;
clrscr();
b.a=10;
textbackground(2);
textcolor(6);
cprintf(" A = %d",b.a);
printf("\n Union = %d",sizeof(b));
printf("\n Structure = %d",sizeof(c));
getch();
}
区别只是 \n 和空格。我的问题是,为什么我的简单程序被检测为病毒?
这是另一个代码示例,这次是 C++:
#include<iostream.h>
#include<conio.h>
class A
{
int a,b;
public:
A()
{
a=0;b=0;
}
A(int x)
{a=x;
b=0;
}
A(int x,int y)
{
a=x;
b=y;
}
~A()
{
cout<<"All things are deleted.";
}
void get()
{
cout<<"\nA = "<<a;
cout<<"\nB = "<<b;
}
};
void main()
{
A a1(5,10);
clrscr();
a1.get();
getch();
}
当我运行这个程序时,它会给出“病毒警告”——即使它不是病毒。现在,悲剧是当您删除析构函数时,它不会将其检测为病毒。
这是屏幕截图和类似的问题:
问题是如何,为什么?