Raised This Month: $ Target: $400
 0% 

Add space on string.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-10-2011 , 23:38   Re: Add space on string.
Reply With Quote #3

PHP Code:
//Change where the space is inserted if you need to
const SpacePos 3;

public 
Test() 
{
    new 
szNumber[] = "123456789123456789";
    new 
szResultNumber32 ];
    
    
SpaceNumberszNumber strlenszNumber ) , szResultNumber charsmaxszResultNumber ) );
    
    
server_print"[%s]" szResultNumber );
    
// [123 456 789 123 456 789]
}

SpaceNumberszNum[] , iLen szResult[] , iSize )
{
    new 
iNumPos iResultPos;
    
    while ( ( 
iNumPos iLen ) && ( iResultPos iSize ) )
    {
        if ( 
iNumPos && !( iNumPos SpacePos ) )
            
szResultiResultPos++ ] = ' ';
            
        
szResultiResultPos++ ] = szNumiNumPos++ ];
    }

__________________

Last edited by Bugsy; 01-10-2011 at 23:42.
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 01:57.


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