30.07.2012, 16:59
Hi! I have a very simply question.
I have a file, and I search for a string in it. If i find the string, I'd like to change that file's line what is including this string.
The problem is that tha changings are in the NEXT line, not in that line where I found my searched string. How can I fix it? Thank you very much.
Zuckerman
I have a file, and I search for a string in it. If i find the string, I'd like to change that file's line what is including this string.
Код:
new File: f; f = fopen( "test1.txt" ); new temp[ 128 ]; while( fread( f, temp )) { if( strfind( temp, "string what i search for", false ) != -1 ) { // Now i know that here is the line what I searched for. // The problem is that, the position in the file is the NEXT line fseek( f, 0, seek_current ); fwrite( f, "here is the string what I want to take to the line" ); } } fclose(f);
Zuckerman