Can anyone please help me ! I want to code a system restart program in C. I also want to know some sites that can help me to start more in C System level.
You would need to use a specific library (dependent on the operating system your coding under) to restart a computer. If you're using Linux, you can simply use this code: #include <stdlib.h> int main(void) { system("reboot"); return 0; } Code (markup): to call the command line "reboot" command. Under Windows, you may need to use something in windows.h, however there may be a command to issue a system restart in Window's command line--I am not sure. Can you be more specific what you mean by "C System level"?
windows version would be #include <stdlib.h> int main( int argc, char *argv[]) { return system( "SHUTDOWN -r -t 01" ); } Code (markup):
Oh, no. Not me! I played with that a bit, fried a couple of motherboards (well, the pieces I was trying to control), and decided that hobby was too expensive for me. Wrox Press has/had a book (I think the title is/was Master Class Assembly Language, or something similar...Vista's decided to flake out again, and I can't pull up Amazon or Google to look it up) that covered some interesting pieces. It was, obviously, assembler rather than C, but it still got into the nitty-gritty of what's *really* going on at the lowest levels. Alternatively, I think I remember a book from a few years back about Linux Kernel Internals (again, I can't look up any details just now). I got the impression that would take you a long way towards where you're wanting to go. OTOH, you make sure you have a good grasp of C and start digging into the Linux source code. Unless you're planning to write device drivers for Windows. That, AFAICT, is truly a black art. Whichever way you go, good luck!
in windows you have the command line shutdown -r -t 0 -f Code (markup): this will force reboot ( -r ) without a timer ( 0 seconds timer ) and will force the running applications to shutdown without warning ( -f ) for more info type shutdown on the windows command line
ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_APPLICATION |SHTDN_REASON_MINOR_INSTALLATION |SHTDN_REASON_FLAG_PLANNED); Code (markup):
Icck! And this is still really only brushing against the edges of "real" programming. At least now we're getting into the level of actual code. Before, we were just making command-line calls, doing crap that anyone can do at any time. There's no point to digging into C unless you're really getting into the internals of how the system really works. It is very valuable to learn. But there's not much point unless you're actually using the details that make it valuable (mainly pointers and actually dealing with hardware). So, thank you r72392 for pulling this thread back onto topic.
It'd help if pulikuttann specified the platform. System-specific functionality is barely covered by the ANSI standard. pulikuttann, are you coding for Windows? Linux? Unix? A Mac? A toaster?
I'm sure it won't be his oven or refrigerator, but I have seen someone write an echo server for a toaster so they could send pings to it