Modifying a file.

This is a discussion on Modifying a file. within the C Programming forums, part of the General Programming Boards category; Hello people, im back for more questions. Recently I posted a question regarding structures(and you were all very helpful) but ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    6

    Modifying a file.

    Hello people, im back for more questions.
    Recently I posted a question regarding structures(and you were all very helpful) but Now I have another problem:
    I have a file with the following:

    <usr>
    <id>1</id>
    <name>John Greer</name>
    <pass>abcdef</pass>
    <status>Active</status>
    </usr>

    How in earth can I modify this file. I want to acces information on a file....
    for example the user wants to modify his password. What kind of restriction can I make so when the terminal finds the '<pass>' and starts reading after the '>' and stops in '</pass>' and modify exactly that part?? so for example

    Terminal:Hello John.
    What is your current password?
    Usr: abcdef
    Terminal: That is correct, do you wish to change it?
    Usr: yes
    Terminal: Ok, give me your new pass.
    User: xyz

    ----and then the file goes from what I first showed you:
    <usr>
    <id>1</id>
    <name>John Greer</name>
    <pass>abcdef</pass>
    <status>Active</status>
    </usr>

    to this:

    <usr>
    <id>1</id>
    <name>John Greer</name>
    <pass>xyz</pass>
    <status>Active</status>
    </usr>

    Very much appreciated guys

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Read everything in. Modify what you want in memory. Write everything out.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Leak in AppWizard-Generated Code
    By jrohde in forum Windows Programming
    Replies: 4
    Last Post: 05-19-2010, 05:24 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  3. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21