title: Why does the terminal show "^[[A" "^[[B" "^[[C" "^[[D" when pressing the arrow keys in Ubuntu?
body: <p>I've written a tiny program in Ansi C on Windows first, and I compiled it on Ubuntu with the built-in GCC now.</p>
  
  <p>The program is simple:</p>
  
  <ul>
  <li>read the line from console with <code>scanf()</code>.</li>
  <li>Analyze the string and calculate.</li>
  </ul>
  
  <p>But something weird happens. When I try to move the cursor, it prints four characters:</p>
  
  <ul>
  <li>pressing <kbd>Up</kbd> prints "<code>^[[A</code>"</li>
  <li>pressing <kbd>Dn</kbd> prints "<code>^[[B</code>"</li>
  <li>pressing <kbd>Rt</kbd> prints "<code>^[[C</code>"</li>
  <li>pressing <kbd>Lt</kbd> prints "<code>^[[D</code>"</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/kJOZP.png" alt=""></p>
  
  <ul>
  <li><p>How can this be avoided?</p></li>
  <li><p>Why does it print these 4 characters instead of moving the cursor?</p></li>
  </ul>