3

I am not able to find the equivalent header file for conio.h (for C programs) in Mac.

I was wondering if there is any option for getch() function in Mac?

I want to use it such that user can give options and program will go forward without pressing enter.

  • 2
    There is no universal solution, the easiest is probably to use ncurses or one of the other suggestions from https://stackoverflow.com/questions/421860/capture-characters-from-standard-input-without-waiting-for-enter-to-be-pressed – UnholySheep Oct 05 '20 at 15:41

1 Answers1

1

You probably want to look at ncurses. It has a lot in common with conio. You can get its documentation with "man ncurses".

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Thanks for the suggestions. I tried with ncurses but its giving me following error: Undefined symbols for architecture x86_64: "_stdscr", referenced from: _main in test-54aaa4.o "_wgetch", referenced from: _main in test-54aaa4.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) – Gopal Srivastava Oct 05 '20 at 16:04
  • Are you linking libncurses? You can't just include the header and not link the library. – Rob Napier Oct 05 '20 at 16:09
  • 1
    Thanks rob. It's working fine now. I was not linking ncurses. I used -lncurses to link the library and now it's working without a hitch. – Gopal Srivastava Oct 05 '20 at 18:05