Raised This Month: $ Target: $400
 0% 

Spaces when coping file contents


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 05-20-2011 , 15:16   Spaces when coping file contents
Reply With Quote #1

When I try to print the contents of a text file to the console or to copy the contents to another file I get spaces between each row. How to remove those spaces?
PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() {
    
register_plugin("test""test""test")
    
register_clcmd("ispraznirede""killmeh")
}

public 
killmeh() {
    new 
iFilePos;
    new 
LineItem[64]
    new 
iFileHandle fopen"omg.txt" "r+t" );

    
iFilePos 0;

    while ( !
feofiFileHandle ) )
    {
        
fgets(iFileHandle LineItem charsmax(LineItem));

        
iFilePos++;
        
        if( 
containLineItem "+") != -)
        {
            
write_file"omg2.txt" LineItem, -1)
       
client_print(0print_consoleLineItem)
        }
    }

    
fclose(iFileHandle);
        
    return 
PLUGIN_HANDLED;

The result:

Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-20-2011 , 15:42   Re: Spaces when coping file contents
Reply With Quote #2

Insert trim(LineItem) after fgets.
__________________
Arkshine is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 05-20-2011 , 16:35   Re: Spaces when coping file contents
Reply With Quote #3

Thanks, it works.
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
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 22:34.


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