Raised This Month: $51 Target: $400
 12% 

read, write and edit files


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
killergirl
Senior Member
Join Date: Jul 2010
Old 03-08-2012 , 14:35   read, write and edit files
Reply With Quote #1

Everytime when I want to insert data in a file I used write_file( , , -1) or fopen( , "a") to save data in files, if the order of lines doesn't matters. If the ordering does matter I used to save each line (format) in a buffer than I could handle it. Today I'm working on a new ranking system, and I need to know how to insert data between specified lines (if input kills higher than stored kills). I know I could do that with storing into a buffer, but I need to reopen the file with write option. With that way I need to use 2 whiles and it has a big working time (if has 5000+ lines), also I need to close than reopen the same file. I think is existing a better way that how I proceed.

In brief, how to edit a file?
killergirl is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-08-2012 , 17:43   Re: read, write and edit files
Reply With Quote #2

IIRC, there is no "simple" method to insert a line. You would need to move every line below the spot you want to insert down one place. This means you need to read every line below the line of interest and re-write it. An SQL or SQL-like system would be much better for this.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode