I was learning about function pointers in C when I came across a program that restarts the computer upon execution.
void (*f) (void);
f=(void (*)(void) MK_FP(0xF
This is a system dependent (ie: non-portable) approach to restarting the machine. What is the intended OS for this program to run on? Is it DOS (I'm assuming). Try running it inside a virtual machine and find out.
If you want this to work on other platforms, you'll need to write some platform specific stuff, like so:
#ifdef __linux__
system("shutdown -P now");
#elif _WIN32
#if (WINVER == NTDDI_WIN7) // Windows 7
system("C:\\WINDOWS\\System32\\shutdown /s");
#endif
#if ((WINVER <= NTDDI_WINXPSP3) && (WINVER >= NTDDI_WINXP)) // Windows XP
system("C:\\WINDOWS\\System32\\shutdown -s");
#endif
#else
#error System not recognized
#endif