Raised This Month: $ Target: $400
 0% 

[SOLVED]Extractstr stock


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 11-28-2007 , 09:42   Re: Extractstr stock
Reply With Quote #3

Did a fx() for you
Should be even much more faster.

Code:
stock extractstr(source[], char1, char2, result[128])     {         new             length = strlen(source),             i, // position of char1 in source             j; // position of char2 in source                     // let's find char1 first ...                 for (i = 0; i < length; i++)             if (source[i] == char1) break;                     if (i < length) // is char1 part of source?             {                 // let's find char2 afterwards ...                                 for (j = i + 1; j < length; j++)                     if (source[j] == char2) break;                                     if (j < length) // is char2 part of source?                     {                         new result_length = j - i + 1;                                                 if (result_length < 128) // is result long enough to hold the string?                             {                                 // return the string and result length                                                                 copy(result, result_length, source[i]);                                 return result_length;                             }                     }             }                     // return empty string and 0                 result[0] = 0;         return 0;     }

Oh btw .. it's also returning a length of the result. Just for a case.
__________________

Last edited by alien; 11-28-2007 at 09:45.
alien is offline
Send a message via ICQ to alien
 



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 11:11.


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