0

I use code::blocks 10.05 for compiling C++.

But I cannot use

getch()

It says unknown. When I #include <conio> it says unknown library. So what is the alternative to be able to use getch in C++?

jogojapan
  • 68,383
  • 11
  • 101
  • 131
Ajay
  • 61
  • 3
  • 13

2 Answers2

2

Try #include <conio.h>

Works fine on my machine (Windows and Linux, mingw compiler for Windows). As I know Code::Blocks uses gcc compiler.

imslavko
  • 6,596
  • 2
  • 34
  • 43
  • thanks.it works. But why does conio alone requires the context 'conio.h' where iostream can be declared simply – Ajay Nov 04 '12 at 06:50
  • 2
    I am not sure, but think because iostream is C++ library and conio.h is from C – imslavko Nov 04 '12 at 06:52
  • 1
    Rather than the extension being implicit to `#include`, the C++ standard library headers actually have no extension. Most other libraries (all that I'm aware of actually) use an extension such as `.h` or `.hpp`. As `#include` takes a full filename, if there is an extension you must add it. – Anthony Burleigh Nov 04 '12 at 07:08
1

Header files with .h extension are different from those without h extension , you may refer this C++ includes with and without .h

Community
  • 1
  • 1
MohdRash
  • 123
  • 1
  • 13