Posted 11 October 2008 - 11:05 AM
I have not really ever learned the correct way to move, resize, or delete data from a file, so I was wondering if anyone knew where on line I could read up on this?
What I normally did before in RQBasic was create two temporary files. Lets say I was deleting position 30 to position 70, I would copy the first contents 0 to 29 to tempfile1 then copy the second contents 71 to eof to tempfile2, then I would copy both files back into one and delete the temp files. Or if I was inserting data then I would devide the file up, append an empty space, or write the data that was being inserted to the end of tempfile1 then copy the files back together.
Also, I would like to know how configuration, text, etc files are handled in C. How are they able to remove a line of data from a file? How do they insert data to the file?
Out of curiosity, all of the tutorials I've seen have never mentioned removing or inserting data. Why do they not discuss this? Is it not used a lot? Or is it something intended on more advanced learning of c programming? It seems that it would be a fairly important thing to learn. When a person is writing in an editor, he moves the cursor to a line, and presses the del key. That information gets deleted, or if he starts typing, then there is data being inserted into the file.
Like I said, I never really tried to learn these parts of programming. So does anyone know of any c tutorials etc online that discuss this?