Hello!
I had a question about appending data in to a file.
My program flows in the following way--
Code:// This function reads data from the file parse_input_data_for_one_algo(some parameters) { FILE *f = fopen (filename, "rw+"); while ( fgets (in_line, 100, f) != NULL ) { //read values } fclose(f); }Code:parse_input_data_for_second_algo(some parameters) { FILE *f = fopen (filename, "rw+"); while ( fgets (in_line, 100, f) != NULL ) { //read values } fclose(f); }My text file is in the following format--Code:// Call to both parse functions in another file which contains the main program int main(int argc, char **argv) { char *filename = argv [1]; parse_input_data_for_one_algo (filename,some parameters); //Algorithm-1 char *filename1 = argv [1]; parse_input_data_for_second_algo (filename1,some parameters); //Algorithm-2 }
I am trying to write additional data from the main file after "Algorithm-1" is solved, in to the text file after all the "z" sx 12 44
y 3 1
y 1 2 -1
z 1 2 1
z 3 1 2
z 4 1 3
z 6 1 4
t 1 2 1 2 1
t 1 2 3 1 2
t 1 3 4 1 1
So my new text file with appended data would look like this --
(1,2,6,9 have been appended to the file)
The new appended text file would now be read by parse_input_data_for_second_algo.x 12 44
y 3 1
y 1 2 -1
z 1 2 1 1
z 3 1 2 2
z 4 1 3 6
z 6 1 4 9
t 1 2 1 2 1
t 1 2 3 1 2
t 1 3 4 1 1
Kindly let me know of alternatives of how I could solve this problem.
Thanks in advance!



LinkBack URL
About LinkBacks


