title: How can I read an input string of unknown length?
body: <p>If I don't know how long the word is, I cannot write <code>char m[6];</code>,<br />
  The length of the word is maybe ten or twenty long.
  How can I use <code>scanf</code> to get input from the keyboard?</p>
  <pre><code>#include &lt;stdio.h&gt;
  int main(void)
  {
      char  m[6];
      printf(&quot;please input a string with length=5\n&quot;);
      scanf(&quot;%s&quot;,&amp;m);
      printf(&quot;this is the string: %s\n&quot;, m);
      return 0;
  }
  </code></pre>
  <p>please input a string with length=5<br />
  input: hello<br />
  this is the string: hello</p>