title: How to read string from stdin until meet blank lines
body: <p>Consider a simple program. It must take string from stdin and save to variable. 
  It is not stated how many lines of input will be taken, but program must terminate if meet newline.</p>
  
  <p>For example:
  stdin:</p>
  
  <pre><code>abc
  abs
  aksn
  sjja
  \n
  </code></pre>
  
  <p>I tried but it doesn't work. Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdio&gt;
  
  using namespace std;
  // Constant
  #define max 100000
  struct chuoi
  {
         char word[10];
  };
  chuoi a[max];
  
  void readStr()
  {
      int i=0;
      while ( fgets(a[i].word, 10,stdin) != NULL)
      {
          if (a[i].word[0] == ' ') break;
          a[i].word[strlen(a[i].word)-1] = '\0'; //replaced \n by \0
          i++;
      }
       //length = i;
  }
  int main()
  {
      readStr();
      return 0;
  }
  </code></pre>
  
  <p>So, how to solve this problem?</p>