Raised This Month: $ Target: $400
 0% 

Solved fseek cannot function as expected


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-28-2020 , 11:23   Re: fseek cannot function as expected
Reply With Quote #3

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)
//to
strcat(text,"^"^n}^n^n}^n^n", charsmax( text ) )
Also, if your string is already prepared/formatted for writing (which it is since you used strcat()), you do not need to use fprintf(), you can use fputs() instead.

fprint() would be appropriate if you wanted to do this.
PHP Code:
new text128 ]
new const 
Fname[] = "test";
    
new 
pList fopen"default_plugins.txt" "a" )
    
if ( 
pList )
{
    
fprintf(pList"^"plugin^"{^n^"name^" ^"%s^"^n^"scRipt^" ^"%s^"^n}^n^n}^n^n" Fname Fname )
    
fclose(pList)

__________________

Last edited by Bugsy; 12-28-2020 at 11:24.
Bugsy is offline
 



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 14:06.


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