std::cout << "Please enter your decision." << std::endl;
startPos = 0;
endPos = 0;
wordsFound = 0;
for ( unsignedint current = 0; current <= sentence.length(); current++ )
endPos = current;
if ( sentence[current] == ' ' || current == sentence.length() ) // Iterate through sentence checking for empty space OR end of string
for ( unsignedint copying = startPos; copying < endPos; copying++ ) // Copy chars from string from start position to end position
word[wordsFound] += sentence[copying];
wordsFound++; // add to words found, queing up next array location for next word
startPos = endPos + 1; // New starting position is one PAST the empty space that was located
if ( wordsFound == LIMIT ) // if more than LIMIT words are found, exit function
Not had time to look at the logic as such but..
is there ever a chance that "wordsFound" variable will be greater than 10 (i.e. the value of LIMIT)?
Also i'd consider using an stl container like std::vector over a horrible c-style array any day.
Also if startPos, endPos, and wordsFound are only going to be used in findWords() then define them as local variables. Similarly for sentance in getCommand(). (although i can see they would be useful member variables if you are going to expand this class).