TPU ChatChat on IRC
Internet Relay Chat?
Java Applet client
Who's on IRC?
Reading/Writing from Files in C
Posted by Mycroft [send private reply] at March 20, 2002, 07:19:01 PM Alright I know how to both read and write from files. But, I would like to be able to do both at the same time. I'm writing to different places in the file, I don't want to over write other information. I know how to use fseek() but that is for a specified amount of bytes, I want to be able to go to a line in the file and write to it there, is that possible?
Posted by taubz [send private reply] at March 20, 2002, 08:12:26 PM I said something similar in another post... If you don't see the function listed, then there isn't any. This is one thing that you should try to figure out how to do using the knowledge that you already have.
As a pointer tho: You can't insert data into the middle of a file (which I think you were saying). If you write to the middle, it's going to overwrite the data there. There's no simple "insert" method.
Posted by Mycroft [send private reply] at March 20, 2002, 10:10:26 PM I do want to write data to the middle so scratch my first idea. If I store all the data to a struct what is the simplest way of writing it back to the file?
Posted by metamorphic [send private reply] at March 21, 2002, 11:39:19 AM Best way would of been to write the file in random access mode in the first place, then you can just insert data whenever you want. If you took that road now you would loose your file.
Posted by RedX [send private reply] at March 21, 2002, 01:01:44 PM Best picture a file as a very big array.
If the file isn't too big (which it probably isn't, unless you're writing a dig. video editor) you could read it in, add the extra data and output it back to a file. (there is much to optimize here)
Register as a new user