Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6046

Why does the terminal show "^[[A""^[[B""^[[C""^[[D" when pressing the arrow keys in Ubuntu?

$
0
0

I've written a tiny program in Ansi C on Windows first, and I compiled it on Ubuntu with the built-in GCC now.

The program is simple:

  • read the line from console with scanf().
  • Analyze the string and calculate.

But something weird happens. When I try to move the cursor, it prints four characters:

  • pressing Up prints "^[[A"
  • pressing Dn prints "^[[B"
  • pressing Rt prints "^[[C"
  • pressing Lt prints "^[[D"

  • How can this be avoided?

  • Why does it print these 4 characters instead of moving the cursor?


Viewing all articles
Browse latest Browse all 6046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>