title: Specific validation of input char array in C++
body: <p>For some time I've had problem in correct validating char array. I've already seen many great ways to do this, but still didn't figured out how to combine few things in my code.
  Can't figure out how to properly resolve this simple problem.</p>
  
  <pre><code> struct student{
      char fullname[SLEN];
      char hobby[SLEN];
      int ooplevel;
      };
  
  int getinfo( student*, int );
  void display1( student );
  void display2( const student* );
  void display3( const student pa[], int );
  
  int main()
  {
      std::cout &lt;&lt; "Group size: ";
      int class_size;
      std::cin &gt;&gt; class_size;
      while( std::cin.get() != '\n' )
          continue;
  
      student* ptr_stu = new student[class_size];
      int entered = getinfo( ptr_stu, class_size );
      for( int i=0; i&lt;entered; ++i )
      {
          display1( ptr_stu[i] );
          display2( &amp;ptr_stu[i] );
      }
      display3( ptr_stu, entered );
      delete [] ptr_stu;
      std::cout &lt;&lt; "Gotowe.\n";
  
      getchar();
      return 0;
  }
  
  int getinfo( student* stu, int n )
  {
      int i=0;
  
      while( i&lt;n ){
  
          std::cout &lt;&lt; "Fullname " &lt;&lt; i+1 &lt;&lt; ": ";
          std::cin &gt;&gt; stu[i].fullname;
  
          std::cout &lt;&lt; "Hobby " &lt;&lt; i+1 &lt;&lt; ": ";
          std::cin &gt;&gt; stu[i].hobby;
  
          std::cout &lt;&lt; "OOPlevel " &lt;&lt; i+1 &lt;&lt; ": ";
          std::cin &gt;&gt; stu[i].ooplevel;
      ++i;
      }
  }
  </code></pre>
  
  <p>I'm just sure that there must be  way to validate char array which:<br>
  1. Maximum length is 30<br>
  2. Must include 2 words, because its first and second name<br>
  3. Cannot include digits<br>
  4. Results in breaking the loop if user press enter without typing anything<br>
  5. And everything is in function which one of arguments is pointer to structure where names will be stored.<br>
  Forgive me for such primitive problem. I know that there isn't even attempt in my code to resolve this, but I've just didn't wanned to put trash I've created here.    </p>