Click here to Skip to main content
15,122,559 members

Comments by Member 15253975 (Top 4 by date)

Member 15253975 21-Jun-21 6:34am View
   
This is my complete code...

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>




void Reboot_System()
{
while(1)
{
char option;
printf("Reboot System\n");
printf("\n This will end the demo. Continue (Y/N)?");
scanf("%c", &option);
if (option == 'y' || option == 'Y')
{
system("reboot");
printf("\n Reboot\n");
while(1);
}
}
}

void Shutdown_System()
{
char option;
printf("Shutdown System\n");
printf(".................");
printf("\n This will end the demo. Continue (Y/N)?");
scanf("%c", &option);
if (option == 'y' || option == 'Y')
{
system("shutdown");
printf("shutdown\n");
}
}

int main()
{
char op;
int n = 0;
while(1)
{
printf("Power Management\n");
printf("................\n");
printf("Options:\n");
printf("1.Reboot\n");
printf("2.Shutdown\n");
// printf("\n0.Quit\n");
scanf(" \n%c", &op);
switch(op)
{
case '1': Reboot_System();
break;
case '2': Shutdown_System();
break;
// case '0': exit(1);
// break;
default : main();
break;

}

}
return 0;

}
Member 15253975 21-Jun-21 6:32am View
   
ok, i tried that but same output came...
Member 15253975 20-Jun-21 9:07am View
   
Thank you very much....
Member 15253975 19-Jun-21 9:27am View
   
Thanks, but i need to go to that path given in the script file then it will reboot...