Problem with std::string::find()
<p>I'm in trouble using std::string::find(). I read strings from console through the following code:</p>

<pre><code> 50   while(command.find(exitString) != 0) {
 51         std::cout &lt;&lt; "$ ";
 52         getline(std::cin, command);
 53 
 54         doSwitch(command);
 55     }
</code></pre>

<p>and then I "switch" on them, through the following function:</p>

<pre><code> 59 void Console::doSwitch(std::string command) {
 60     if(command.find(helpString) == 0) {
 61         help();
 62     } else if(command.find(loadString) == 0) {
 63         try {
 64             doLoad(command);
 65         } catch(std::string str) {
 66             std::cout &lt;&lt; str &lt;&lt; std::endl;
 67         }
 68     } else if(command.find(dumpProcString) == 0) {
 69         try {
 70             doDumpProc(command);
 71         } catch(std::string str) {
 72             std::cout &lt;&lt; str &lt;&lt; std::endl;
 73         }
 74     } else if(command.find(dumpMemString) == 0) {
 75         doDumpMem();
 76     } else if(command.find(defmemString) == 0) {
 77         try {
 78             doDefmem(command);
 79         } catch(std::string str) {
 80             std::cout &lt;&lt; str &lt;&lt; std::endl;
 81         } catch(char *str) {
 82             std::cout &lt;&lt; str &lt;&lt; std::endl;
 83         }
 84     } else if(command.find(resetString) == 0) {
 85         try {
 86             doReset();
 87         } catch(std::string str) {
 88             std::cout &lt;&lt; str &lt;&lt; std::endl;
 89         }
 90     } else {
 91         std::cout &lt;&lt; "Comando inválido." &lt;&lt; std::endl;
 92     }
 93 }
</code></pre>

<p>but sometimes it simply doesn't switch correctly. Any clues?</p>

<p>Thanks in advance,</p>

<p>EDIT:
I've done some tests and I detected it was falling on the last else-if statement, instead of falling on the last else.
Then I checked my code again and found that the root cause was that I forgot to initialize resetString.
Problem solved!
Thank you everyone.</p>
