0

Can someone give me a good alternative for getch() function in c++ ? I want to read signs from keyboard and getch makes error on ideone and on online judge in codeblocks all goes well.

Butter
  • 23
  • 5
  • 3
    Possible duplicate of [Alternative function in iostream.h for getch() of conio.h?](https://stackoverflow.com/questions/1377403/alternative-function-in-iostream-h-for-getch-of-conio-h) – user4581301 Feb 13 '18 at 07:38
  • Write your own `getch()`. Here's the link: https://stackoverflow.com/questions/7469139/what-is-equivalent-to-getch-getche-in-linux – kiner_shah Feb 13 '18 at 08:09

1 Answers1

2

try below

int ch = std::cin.get();

Roledenez
  • 751
  • 4
  • 16
  • 43
  • `std::cin.get()` performs a buffered input while `getch()` peformes unbuffered input. On my system that practically means that I need to press `Enter` twice with `std::cin.get()` – George Robinson Feb 06 '21 at 11:25