Advertisement
Ember

readword

Sep 28th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. // ------------------------------------------------------------------------------------
  2. String File::ReadWord()
  3. {
  4.     String word;
  5.     UByte letter;
  6.  
  7.     Bool done = false;
  8.     // Trim any spaces possibly preceeding the actual text
  9.     while(!End && !done)
  10.     {
  11.         letter = Read<UByte>();
  12.  
  13.         if(std::isalnum(letter))
  14.         {
  15.             // Append the letter and begin parsing the rest of the word
  16.             word += letter;
  17.             done = true;
  18.         }
  19.         else
  20.         {
  21.             // Discard this letter by not doing anything
  22.         }
  23.     }
  24.  
  25.     done = false;
  26.     while(!End && !done)
  27.     {
  28.         letter = Read<UByte>();
  29.  
  30.         if(std::isalnum(letter))
  31.         {
  32.             // Append the letter and continue parsing the rest of the word
  33.             word += letter;
  34.         }
  35.         else
  36.         {
  37.             // Character past the end of the word means we're done
  38.             done = true;
  39.         }
  40.     }
  41.  
  42.     return word;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement