title: When I try to input a string in C++, the program throws out a run time error
body: <p>I am trying to input a string in a C++ file by using <code>scanf()</code> (the compiler warns me to change <code>scanf()</code> to <code>scanf_s()</code>, so I changed it).</p>
  <pre><code>char string[3];
  scanf_s(&quot;%s&quot;, string);
  printf(&quot;%s&quot;, string);
  </code></pre>
  <p>I input &quot;abc&quot; in the console and press enter. Then the program will throw out the exception below</p>
  <blockquote>
  <p>Exception thrown at 0x00007FF9C35B2079 (ucrtbased.dll) in
  Project1.exe: 0xC0000005: Access violation writing location
  0x0000008DD5D00000.</p>
  </blockquote>
  <p>I can't figure out the error.</p>