fseek cannot function as expected
1 Attachment(s)
Hi everyone, I am a freshman start to write amxx scripts recently, I want to start with a file logger as my practice:), when I try to append additional text to the second to the last line, weird thing (or it's just my misuse of file operation functions) happend.
1.open file with "at", I cannot set cursor for the file, and the text is always append to the last 2.open file with "wt", I can set cursor but the position is no counted by lines but bytes or bits? I set cursor using fseek to the 30th line (if the second param of fseek represents the target lineNo), but ended up with a new text file with 30 ? symbol (could not be recognize by utf-8 decoder) appended by my new text amxx: Code:
AMX Mod X 1.8.2 (http://www.amxmodx.org)Code:
public reload_as()before execution, the target file (UTF-8,CRLF): Code:
//========================================Code:
??????????????????????????????"plugin"{It's my first time posting a thread, if there is any violation against rules, I sincerely apologize.:oops::cry: If anyone could answer my question, I'd be very appreciate for it, Thx!:) |
Re: fseek cannot function as expected
This is how I solved this problem:
Code:
new text[128] |
Re: fseek cannot function as expected
You can avoid using fseek() by adding 2 new-lines (^n^n) at the end of your text. Since you currently end your file write with "}", the next append is going to begin immediately after that character, it does not know that you first want to insert 2 new-lines before writing the new text.
Code:
strcat(text,"^"^n}^n^n}",128)fprint() would be appropriate if you wanted to do this. PHP Code:
|
Re: fseek cannot function as expected
Quote:
|
| All times are GMT -4. The time now is 14:06. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.