病毒程序示范
1 /* 2 龌龊的程序! 3 */ 4 # include <stdio.h> 5 # include <windows.h> 6 # include <malloc.h> 7 #include<cstdlib> 8 9 int main(void) 10 { 11 int c; 12 int i; 13 int j; 14 15 Nihao: 16 printf("1:死机 "); 17 printf("2:机房爆炸 "); 18 printf("请选择: "); 19 20 scanf("%d,&c"); 21 22 if (c ==1) 23 { 24 system("shutdown -s -t 60"); 25 } 26 else if (2 == c) 27 { 28 printf("你太坏了 我要惩罚你! "); 29 for (j=0;j<10;++j){ 30 system("start"); 31 } 32 } 33 else 34 { 35 printf("你敲错了,请重新输入! "); 36 goto Nihao; 37 } 38 return 0; 39 }
内存泄露(占满内存)程序导致死机实例
1 #include < stdio.h > #include < malloc.h > 2 3 int main(void) { 4 while (1) { 5 int * p = (int * ) malloc(1000); 6 } 7 return 0; 8 }