Thread: Help to write a program

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Help to write a program

    Hi,

    I want a c program to edit certain files in the windows root directory i.e c:\windows. Can anybody give me the program code to change from the current directory to the root directory.

    Thanks in advance,

    Regards,

    vinith98

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    chdir is the function you want.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    Thanx Elysia...
    but how do i use chdir() yo go to the root of the OS ??
    What are the parameters i should use ??

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I can't imagine that you should be editing files in the Window directory, in the first place.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So why exactly do you want to edit files there?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    Not exactly in the windows directory...
    I want to edit the host file in the C:\WINDOWS\system32\drivers\etc directory...

    chdir("\\") should work right ??

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Why do you want to edit the host file? Sorry for asking, but it's against the rules to help with malicious software, so if you could just tell us why so we know what you're doing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    Nothing to do with any kind of malicious software, m jus tryin to learn C, thats it...

    Jus read about the host file on a forum, so jus tryin to play around with it.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Why not edit manually?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Why do you want to delete and edit something from the system file folder. If you are trying to learning or do something, try it on a different dirctory and see. Then when you are sure about what you are doing then go ahead. Changing stuff under windows directory is not a good idea unless u know what u are doing.

    ssharish

  11. #11
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    ya got it...

    Anyways thanks for the advice.

    Vinith

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie needs help..
    By xpress urself in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2007, 07:22 PM
  2. how could i write this program: cat < apa | wc | wc > bepa
    By strugglingman in forum C Programming
    Replies: 2
    Last Post: 04-26-2006, 04:40 PM
  3. Is there another way to write this program?
    By agentxx04 in forum C Programming
    Replies: 1
    Last Post: 11-23-2004, 09:28 PM
  4. Replies: 1
    Last Post: 10-13-2004, 12:15 PM
  5. Challenge to write a program
    By Twisted.alice in forum A Brief History of Cprogramming.com
    Replies: 40
    Last Post: 05-15-2003, 12:00 PM