Skip to content

Instantly share code, notes, and snippets.

@svolpe43
Last active April 1, 2017 00:15
Show Gist options
  • Save svolpe43/01cce356c5e816f59f8f5f2c15fbb0fd to your computer and use it in GitHub Desktop.
Save svolpe43/01cce356c5e816f59f8f5f2c15fbb0fd to your computer and use it in GitHub Desktop.
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