1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C: Question on file handling

  1. Nov 7, 2015 #1
    1. The problem statement, all variables and given/known data
    How to delete specific record from a text file by some field from struct?

    2. Relevant equations
    -File handling
    -Searching algorithms

    3. The attempt at a solution
    I know that one of the searching algorithms is needed, but could someone explain how to
    delete found record from file?
  2. jcsd
  3. Nov 7, 2015 #2


    Staff: Mentor

    Here's what I would do:
    While the applicable field is not found:
    1. Read each record from the file into memory.
    2. If the field you're looking for does NOT match the value you're looking for, write the record to the file; otherwise (not a match) don't do anything.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Threads - Question file handling Date
Opamp questions Thursday at 8:19 PM
Fundamentals of Electric Circuits - Sadiku Question on KVL Tuesday at 1:37 AM
Stress Transformation Question-Mechanics of Materials Mar 13, 2018
Opamp circuit question Mar 7, 2018
C++ File Reading Question Nov 3, 2013