When winter is over, the leaves fall, And the geese fly south in a B-or T-shaped manner, the programmers are still playing the keyboard in the cold computer. As a good programmer, we can use a program to solve all the problems except our wives. What's more, it's a little cold wind. Next we will use C to write a heater.
Theoretically, computers consume electricity. In addition to the luminous voice, this part of electricity is used for fever. Simply put, the CPU, hard disk, and even memory are all hot due to work. Taking into account the versatility of the program, we do not consider the video card sound card drive, we use memory read and write to make the memory fever, use a lot of computing to make the CPU fever, use file read and write to heat the hard disk, finally, we can make the computer a small heater.
The code that heats up the CPU is as follows:
DWORD winapi cpuhotter (pvoid para)
{
While (1 );
Return 1;
}
The code that heats up the memory is as follows:
DWORD winapi memhotter (pvoid para)
{
Char * mem = new char [10000];
While (1)
{
For (INT I = 0; I <10000; I ++)
{
Mem [I] = 0x99;
}
}
Return 1;
}
Finally, the code that heats up the hard disk:
DWORD winapi diskhotter (pvoid para)
{
File * FP;
Fp = fopen ("_", "A + ");
While (1)
{
For (INT I = 0; I <10000; I ++)
{
Fwrite ("1", 1, 1, FP );
}
Rewind (FP );
}
Return 1;
}
The main function can be used to create the above three threads. This code is compiled and run successfully in the athlon 1.26 + 256 m + VC 6.0 environment. Windows 2000 runs for three days and the indoor temperature continues to rise. It is proposed to apply for a national patent. Inspired by open-source ideas, the source code is released, hoping to bring you a warm winter.
Thank you.