answersLogoWhite

0

Why do you use conio.h?

Updated: 8/11/2023
User Avatar

Wiki User

12y ago

Best Answer

You include stdio.h when writing C code. If you are writing C++ code then you must include cstdio instead. Both headers implement the C standard input and output library but cstdio is compliant with C++.

Consider the following :

#include

int main()

{

printf("Hello world\n");

std::printf("Hello world\n"); // ERROR!

}

The error occurs because there's no guarantee the printf symbol resides in the std namespace. There's a small possibility it does reside there, but it is only guranteeed to exist in the global namespace. Thus the risk of error is high.

Now consider the following:

#include // also includes stdio.h

int main()

{

using std::printf;

printf("Hello world\n");

std::printf("Hello world\n");

}

The cstdio header guarantees all symbols defined in stdio.h now appear in the std namespace (where all standard library symbols rightly belong). Although there's no guarantee those same symbols also reside in the global namespace, the using keyword can be used to inject those symbols into the global namespace. In this case the using keyword is unnecessary; the code will compile with or without it.

It's important to recognise the difference between C++ standard library headers (those with no extension) and the equivalent C headers (those with a .h extension). C headers guarantee all symbols are imported to the global namespace and possiblythe std namespace. C++ headers guarantee all symbols are imported to the std namespace and possibly the global namespace. In most cases, the C++ header simply modifies the equivalent C header to render it compliant with C++. This isn't always the case, but ultimately it is much easier to inject symbols to the global namespace (with using) than it is to inject to the std namespace. The C++ headers take care of all the messy stuff for you and are less problematic in the long run.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

You write #include and/or #include in a C or C++ program to "include" the files "stdio.h" or "conio.h" into your program. Its the same as opening those files in an editor, and copy/pasting them into your program at the point where the #include statement is.

If you look at these files, you will see macro definitions and function declarations. These are things that you need in order to be able to use the related libraries stdio.lib and/or conio.lib. Almost every C program will use stdio.h and/or stdlib.h, because those represent the standard run-time library. The conio.h file is specialized to make it easy to do special things with the console, such as do something on a keystroke without needing to press enter.

To find these files, look in the compiler's install directory, in the lib sub-directory. Just don't change anything in these directories, because they are a part of the compiler and run-time library. (To protect yourself, I suggest that you change your editor's default "save-on-exit" option to "ask", rather than "auto-save". This way, you won't accidentally change something that you shouldn't.)

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

conio.h is used for "Console Input/Output" function.

It is often used with text-based user interface programs. It has functions such as getch() which waits for a key to be pressed.

It also has color related functions. You can use them to change the color of text or background in a console application. It also has functions related to cursor movements, such as gotoxy().

conio.h is found in old MS-DOS compilers, such as Turbo C and is not widely supported.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why do you use conio.h?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you use conioh header in c plus plus?

just as you do it in C.


What is the full form of conioh?

Console Input Output Header


What is the difference between stdioh and conioh?

Their name, content and function.


What is the function of conioh in C?

Not in C, only in TurboC.Direct console input-output (MS-DOS specific).


Functions of conioh and processh header files?

Loads of them. Consult your help, or load these headers into a text-editor.


Why cannot you include conioh in your c program when you program in Linux system?

You could, if you had conio.h in linux, but you don't have, that's why.


What does conioh in programming mean?

conio.h is a library function which is predefined in the header file and 'clrscr();','getch();' and many other functions come under this.


Which library file contain the definition of stdioh and conioh header file function definition in C language?

Platform dependent, possibly LIBC.LIB or something like that.


When to use me and you or you and i?

If you would use 'I' in the singular, then use 'you and I'. If you would use 'me', then use 'you and me'.


Where is All of the imvu use codes?

they are mostly actions it has some moods CODES: *use 90-pacman *use 200-tresure chest *use 2001-banna *use 2044-cry *use 2050-oooh *use 2053-Puke *use 2061-Huh *use 2063-wassamatta *use 2064-yay *use 2066-Loser *use 2067-shocked *use2068-rocker *use 2072-Flip *use 2073-air guitar *use 2074-talk to the hand *use 2076-Burp *use 2078-Crazy *use 2082-bigyawn *use 2086-strong *use 2088-score *use 2090-wink *use 2091-HeadShake *use 2093-thums up *use 2097-Hmm *use 2098-candlestick *use 2103-old mood *use 2104-flirty mood *use 2105-bashful mood *use 2106-groovin mood *use 2107-peace *use 2108-fartarm *use 2109-terrifide mood *use 2110-tantrum


What do you use to work out equations on excel?

You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.You use the formulas and functions.


How do you do 1394 divided by 36?

38.7222