title: Simple Character Validation in C++
body: <p>I am a beginning programmer and new to C++, and am looking to learn.  This is what I have so far:</p>
  
  <p>This psuedo-code version an instructor provided me:</p>
  
  <pre><code>if str.find("@")==string::npos OR &lt;-- @ not found
  
  str.find(".")==string::npos OR &lt;-- . not found
  
  str.find(" ")!=string::npos) &lt;-- space found
  </code></pre>
  
  <p>And my understanding of the function's requirements:</p>
  
  <pre><code> check emails for @, ., or space  function,
  
   if @ exists, no output
   if @ doesn't exist, output "This (email) is invalid."
   if . exists, no output
   if ' ' exists, output "This (email) is invalid."
  </code></pre>
  
  <p>Here is my sorry attempt that doesn't work:</p>
  
  <pre><code>void Roster::printIncorrectEmails()
  {
  char at = '@';
  char pd = '.';
  char sp = ' ';
  
  for (int i = 0; i &lt; sizeof(RepoArray); i++) {
  
      string email = Student::RepoArray.getEmailAddress();
  
      size_t found = email.find(at, pd);
      if (found != string::npos)
      {
          cout &lt;&lt; "Invalid Email: " &lt;&lt; email &lt;&lt; '\n';
      }
  
      found = email.find(sp);
      if (found == string::npos)
      {
  
          cout &lt;&lt; "Invalid Email: " &lt;&lt; email &lt;&lt; '\n';
      }
  }
  }
  </code></pre>
  
  <p>I've got plenty of other attempts too, if anyone cares to see them. </p>