简体   繁体   中英

Defining getch() function in c/c++

Why when I use getch() function in c++, I should include "conio.h" header file... while in c it runs without include this file?

I'm using codeBlocks as my IDE.

I expect that I must include "conio.h" in c program also, and I tried to include "stdio.h" and "stdlib.h" in c++ program but there is no result.

Why when I use getch() function in c++, I should include "conio.h" header file...

C++ requires that identifiers be declared before they are used.

… while in c it runs without include this file?

You are using an implementation of an old version of C in which a function call with an undeclared identifier defaulted to treating the identifier as one for a function with undeclared parameters with return type int .

I'm using codeBlocks as my IDE.

The IDE is irrelevant, except that there are some associations between some IDEs and some sets of development tools. The critical information is the name and version number of the compiler and the switches you are giving to it. Saying what IDE you are using is like saying what picture frame you are using in a question about a picture. The frame does not identify the picture, and the IDE does not identify the compiler you are using inside the IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM