Difference between stdio.h and conio.h
stdio.h
stdio.h stands for standard input-output header in C programming. This header file contains definitions for functions like printf(), scanf(), getchar(), putchar(), etc., which are standard input/output library functions in C.
Here is an example of stdio.h usage:
#include
int main() { int number; printf("Enter a number: "); scanf("%d", &number); printf("You entered: %d", number); return 0; }
In the above code, stdio.h is included at the top which allows the use of printf() for output and scanf() for input.
conio.h
conio.h stands for console input-output. This header file is specific to the DOS operating system and contains functions for console input/output operations. It's not part of the C standard library, so its use is generally discouraged due to its non-portable nature. It includes functions like getch(), clrscr(), kbhit(), etc.
Here is an example of conio.h usage:
#include
int main() { char ch; printf("Press a key to continue..."); ch = getch(); // Waits for a key press return 0; }
In the above code, getch() is a function from conio.h which waits for the user to press a key.
Differences between stdio.h and conio.h
- stdio.h is a standard C library for input/output operations while conio.h is specific to DOS and is used for console I/O operations.
- stdio.h is portable across different platforms whereas conio.h is not portable and mostly not present in modern compilers like GCC.
- The stdio.h library provides functions like printf(), scanf(), fopen(), fclose(), etc. which are universally recognized, while conio.h provides functions like clrscr(), getch(), kbhit(), which are not universally recognized.
- conio.h has functions that can be used for changing text color, moving the cursor, etc. These functionalities are not provided by stdio.h.
- Functions provided by conio.h are generally faster than stdio.h because they don't perform buffering of input/output operations.
It's important to note that because conio.h is not part of the standard C library, using it can lead to code that only works on certain systems or compilers. For this reason, many programmers avoid using conio.h and stick to the standard C library functions for input/output.
Replies
-
PROSENJIT
You write [HASHTAG]#include[/HASHTAG]Akhil VijayCan anyone please let me know the difference between stdio.h & conio.h and where & when these header files should be used?and [HASHTAG]#include[/HASHTAG] in a C or C++ program to "include" the files "stdio.h" or "conio.h" into your program. It's the same as opening those files in an editor, and copy/pasting them into your program at the point where the [HASHTAG]#include[/HASHTAG] statement is.
contain some functions prototypes like printf(), scanf(), cout,cin.
contain some functions prototypes like clrscr(), getch(), getche() etc.
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. 😀 -
Akhil Vijay
Thank you very much. Is it necessary to use both the header files in every program that we do?PROSENJITYou write [HASHTAG]#include[/HASHTAG]and [HASHTAG]#include[/HASHTAG] in a C or C++ program to "include" the files "stdio.h" or "conio.h" into your program. It's the same as opening those files in an editor, and copy/pasting them into your program at the point where the [HASHTAG]#include[/HASHTAG] statement is.
contain some functions prototypes like printf(), scanf(), cout,cin.
contain some functions prototypes like clrscr(), getch(), getche() etc.
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. 😀 -
Sanyam Khurana
STDIO means Standard Input Output. It has some pre-defined functions like int printf(), scanf() etc. CONIO stands for Console Input Output which has some functions like clrscr(), getch() etc.Akhil VijayCan anyone please let me know the difference between stdio.h & conio.h and where & when these header files should be used?
conio.h header file isn't used anymore. It was used in old Turbo C compiler which are 16-bit and all your programs run virtually on 8086 microprocessor. So, if you understand how the memory is divided in 8086, you will un-leash must of the logic C uses internally.Akhil VijayThank you very much. Is it necessary to use both the header files in every program that we do?
Do not use Turbo C, use gcc or something that uses wrapper to gcc like CodeBlocks IDE.
Also, your header files should not be placed like:
[HASHTAG]#include[/HASHTAG]
[HASHTAG]#include[/HASHTAG]
// rest of the program
The proper way to do this would be:
[HASHTAG]#include[/HASHTAG]
using namespace std;
// rest of the program.
I hope this would be a good pointer for you. -
Akhil VijaySanyam KhuranaSTDIO means Standard Input Output. It has some pre-defined functions like int printf(), scanf() etc. CONIO stands for Console Input Output which has some functions like clrscr(), getch() etc.
conio.h header file isn't used anymore. It was used in old Turbo C compiler which are 16-bit and all your programs run virtually on 8086 microprocessor. So, if you understand how the memory is divided in 8086, you will un-leash must of the logic C uses internally.
Do not use Turbo C, use gcc or something that uses wrapper to gcc like CodeBlocks IDE.
Also, your header files should not be placed like:
[HASHTAG]#include[/HASHTAG]
[HASHTAG]#include[/HASHTAG]
// rest of the program
The proper way to do this would be:
[HASHTAG]#include[/HASHTAG]
using namespace std;
// rest of the program.
I hope this would be a good pointer for you.
Thank you very much for the info.Sanyam KhuranaSTDIO means Standard Input Output. It has some pre-defined functions like int printf(), scanf() etc. CONIO stands for Console Input Output which has some functions like clrscr(), getch() etc.
conio.h header file isn't used anymore. It was used in old Turbo C compiler which are 16-bit and all your programs run virtually on 8086 microprocessor. So, if you understand how the memory is divided in 8086, you will un-leash must of the logic C uses internally.
Do not use Turbo C, use gcc or something that uses wrapper to gcc like CodeBlocks IDE.
Also, your header files should not be placed like:
[HASHTAG]#include[/HASHTAG]
[HASHTAG]#include[/HASHTAG]
// rest of the program
The proper way to do this would be:
[HASHTAG]#include[/HASHTAG]
using namespace std;
// rest of the program.
I hope this would be a good pointer for you. -
pratap singh, upendra
Could you please shed some light on the difference between Standard Input Output and Console Input Output?Sanyam KhuranaSTDIO means Standard Input Output. It has some pre-defined functions like int printf(), scanf() etc. CONIO stands for Console Input Output which has some functions like clrscr(), getch() etc.
Just give the striking difference between them. Technical details are not required as of now. -
pratap singh, upendra
Are header files really a part of compiler?PROSENJITTo 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
As per my knowledge, they are a part of run-time library where the developers have written codes that could be used by the programmers instead of reinventing the wheel.
Correct me if I am wrong... -
Suresh Babustdio.h is part of c language standard library header. conio.h is an additional library header file provided by BORLAND TURBO C. There are some common functions between these two libraries.
-
rajmanishastdio.h is the header of c programming language which means Standard input output. It has pre-defined functions like int printf(), scanf() etc. conio.h is Console Input Output which include functions like clrscr(), getch() etc.
You are reading an archived discussion.