Restarting in C !!!

Discussion in 'Programming' started by pulikuttann, Mar 30, 2007.

  1. #1
    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.
     
    pulikuttann, Mar 30, 2007 IP
  2. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #2
    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"?
     
    SeLfkiLL, Mar 30, 2007 IP
  3. pulikuttann

    pulikuttann Banned

    Messages:
    1,839
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #3
    " C System Level " means interacting more with computer hardwares !!!
     
    pulikuttann, Mar 30, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    windows version would be

    
    #include <stdlib.h>
    
    int main( int argc, char *argv[])
    {
    	return system( "SHUTDOWN -r -t 01" );
    }
    
    Code (markup):
     
    krakjoe, Mar 31, 2007 IP
  5. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    So, are you talking about things like device drivers and such?
     
    jimrthy, Mar 31, 2007 IP
  6. pulikuttann

    pulikuttann Banned

    Messages:
    1,839
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yeah !!!
    That's it.
    Plz help !
     
    pulikuttann, Mar 31, 2007 IP
  7. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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!
     
    jimrthy, Apr 2, 2007 IP
  8. pulikuttann

    pulikuttann Banned

    Messages:
    1,839
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #8
    thank !
    Can u plz get me some sites with the tutorial !!!
     
    pulikuttann, Apr 2, 2007 IP
  9. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #9
    jimrthy, Apr 14, 2007 IP
  10. JFS

    JFS Active Member

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #10
    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
     
    JFS, Apr 16, 2007 IP
  11. pulikuttann

    pulikuttann Banned

    Messages:
    1,839
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #11
    This is only possible in Win XP dear !
     
    pulikuttann, Apr 16, 2007 IP
  12. r72392

    r72392 Peon

    Messages:
    28
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    ExitWindowsEx(EWX_POWEROFF,
      SHTDN_REASON_MAJOR_APPLICATION
      |SHTDN_REASON_MINOR_INSTALLATION
      |SHTDN_REASON_FLAG_PLANNED);
    Code (markup):
     
    r72392, Apr 18, 2007 IP
  13. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #13
    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.
     
    jimrthy, Apr 20, 2007 IP
  14. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #14
    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?
     
    SeLfkiLL, Apr 20, 2007 IP
  15. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #15
    lol, a toaster prolly ..... possibly an electric oven .....
     
    krakjoe, Apr 21, 2007 IP
  16. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #16
    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 :p
     
    SeLfkiLL, Apr 21, 2007 IP
  17. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Now that is geekdom at its finest!
     
    jimrthy, Apr 21, 2007 IP