45 C Program to Shutdown or Turn Off the Computer in Linux
Posted by Superadmin on December 23 2015 03:33:12
his C Program shutdowns or turn offs the computer in linux.
Here is source code of the C Program to shutdown or turn off the computer in linux. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C Program to Shutdown or Turn Off the Computer in Linux.
*/
#include <stdio.h>

int main()
{
system("shutdown -P now");
return 0;
}

$ cc pgm57.c
$ a.out
shutdown: Need to be root