Thread: Retrieve specific data from text for edit

  1. #1
    Unregistered
    Guest

    Question Retrieve specific data from text for edit

    turbo c++ 4.5 compiler
    Win ME

    -----
    I'm using fprintf to store the data
    this is the content of .txt

    Ryo Sakazaki
    123 pacific parkway
    25
    Japanese

    Abc
    22, mountainview
    20
    Irish

    def ga
    45, bla bla
    19
    Chineze.

    Question..
    1) How do i retrive the second record for edit n then save it to the same location?
    I have no idea how to make t works. Could some 1 pls help me by providing me an example codes.

    thanks

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    You cannot change only one line in the file if it has no fixed length.

    You need to read the whole file, make your changes, and print the whole file again.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Unregistered
    Guest
    you could use a structure to store a record and malloc to store the file temporarily till you make the changes, close the file, open again for writing and store back from malloc to file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading data from a text file
    By Dark_Phoenix in forum C++ Programming
    Replies: 8
    Last Post: 06-30-2008, 02:30 PM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  4. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM