2

I need a cross platform way of handling this:

When I press enter in "cin" line, I want it to clear everything processed including the newline.

Is it even possible? Or do I need to find some crossplatform getch() implementation and do it that way?

user1873947
  • 1,781
  • 3
  • 27
  • 47
  • Please explain what you mean with "clear everything processed". It could mean different things to different people. – Bart van Ingen Schenau Jan 14 '13 at 19:22
  • Clean the text entered and the newline entered by pressing enter. – user1873947 Jan 14 '13 at 19:24
  • I think it boils down to `getch()` (== POSIX standard). That's why I asked for your actually used OSs in your [last question](http://stackoverflow.com/questions/14324663/cross-platform-way-of-having-non-blocking-console-input). There are (at least partial) POSIX compliant implementations for linux and windows actually (same for ncurses). I've also seen hints that `getch()` is deprecated for use in windows and one should use [`_getch()`](http://msdn.microsoft.com/en-us/library/078sfkak%28v=vs.80%29.aspx) instead. – πάντα ῥεῖ Jan 14 '13 at 19:30
  • You mean, like a terminal-based IRC chat? You type your text, hit "enter", your message area becomes clean? – Thiago Negri Jan 14 '13 at 19:42
  • @Thiago Negri exactly that. – user1873947 Jan 14 '13 at 21:02

1 Answers1

4

The only cross-platform way I can see is to forego the standard input and output streams altogether, and use something like ncurses (which have a Windows port).

It can handle reading keys directly, with or without echoing, and can clear the screen.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621