Last active
April 1, 2017 00:15
-
-
Save svolpe43/01cce356c5e816f59f8f5f2c15fbb0fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CardProcessor::FindBlankLengthAndIndex(Card *card) { | |
unsigned int i = 0; | |
int j = 0; | |
int blankIndex = 0; | |
int blankLength = 0; | |
string buffer = card->GetStr(); | |
bool foundBlank = false; | |
for (i = 0; i < (buffer.length()); i++) { | |
if (buffer[i] == '_') { | |
if(foundBlank) { | |
card->SetBlankLength(0); | |
return; // so it doesnt execute any more code | |
// to break; if you want to just exit the for loop | |
} | |
foundBlank = true; | |
blankIndex = i; | |
j = i; | |
while (buffer[j] != ' ') { | |
blankLength++; | |
j++; | |
} | |
} | |
} | |
NOTE: No card->SetBlankIndex when its invalid? | |
if (blankLength < 3) { | |
card->SetBlankLength(0); | |
} | |
else { | |
card->SetBlankLength(blankLength); | |
card->SetBlankIndex(blankIndex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment