ZoriaRPG

String_LoadInt.zh

Jul 17th, 2018
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Find the value of an integer that has been found in a string
  2. int String_LoadInt(int str, int startIndex){
  3.     int digits[5];
  4.     int numDigits;
  5.     int i;
  6.     while ( !isNumber(str[i+startIndex]) ) ++i;
  7.     while( numdigits < 5 )
  8.     {
  9.         if ( !isNumber(str[i+startIndex]) ) break;
  10.         digits[numDigits] = str[i+startIndex];
  11.         ++numDigits;
  12.     }
  13.     int rv;
  14.     for( i = 0; isNumber(digits[i]); ++i)
  15.     {
  16.         rv = rv*10 + (digits[i] - '0');
  17.     }
  18.     return rv;
  19. }
  20.  
  21. //Find the value of an integer that has been found in a string
  22. int String_LoadInt(int str, int startIndex){
  23.     int digits[5];
  24.     int numDigits;
  25.     int i;
  26.     while ( !isNumber(str[i+startIndex]) )
  27.     {
  28.         if ( str[i+startIndex] == 0 ) return 0; //breaka nd return 0 on error
  29.         ++i;
  30.     }
  31.     while( numdigits < 5 )
  32.     {
  33.         if ( !isNumber(str[i+startIndex]) ) break;
  34.         digits[numDigits] = str[i+startIndex];
  35.         ++numDigits;
  36.     }
  37.     int rv;
  38.     for( i = 0; isNumber(digits[i]); ++i)
  39.     {
  40.         rv = rv*10 + (digits[i] - '0');
  41.     }
  42.     return rv;
  43. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×