Assuming y are on linux, you can use the
reboot()
system call: see
here[
^]
Alternatively, you can use the
system()
e.g.
system("/usr/sbin/reboot");
Depending on your use case, maybe
/usr/sbin/shutdown
might be a better option. The shutdown command has additional arguments to allow a grace period before the system goes down so
shutdown -r +5
tells the system to reboot (-r flag) in 5 minutes, and sends a warning to all users about the impending reboot.