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

  1. 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.
  2. stdio.h is portable across different platforms whereas conio.h is not portable and mostly not present in modern compilers like GCC.
  3. 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.
  4. conio.h has functions that can be used for changing text color, moving the cursor, etc. These functionalities are not provided by stdio.h.
  5. 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
    PROSENJIT
    Akhil Vijay
    Can anyone please let me know the difference between stdio.h & conio.h and where & when these header files should be used?
    You 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. 😀
  • Akhil Vijay
    Akhil Vijay
    PROSENJIT
    You 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. 😀
    Thank you very much. Is it necessary to use both the header files in every program that we do?
  • Sanyam Khurana
    Sanyam Khurana
    Akhil Vijay
    Can anyone please let me know the difference between stdio.h & conio.h and where & when these header files should be used?
    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 Vijay
    Thank you very much. Is it necessary to use both the header files in every program that we do?
    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.
  • Akhil Vijay
    Akhil Vijay
    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.


    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.
    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.


    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.
  • pratap singh, upendra
    pratap singh, upendra
    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.
    Could you please shed some light on the difference between Standard Input Output and Console Input Output?
    Just give the striking difference between them. Technical details are not required as of now.
  • pratap singh, upendra
    pratap singh, upendra
    PROSENJIT
    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
    Are header files really a part of compiler?

    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 Babu
    Suresh Babu
    stdio.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.
  • rajmanisha
    rajmanisha
    stdio.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.

Related Posts

In their latest path breaking research work, a researcher trio from UC Berkeley, Arizona State University and University of Toronto, have made it possible to convert sunlight into liquid fuel,...
It's official, because it's from Phil Schiller to his colleagues at Apple! OSX El Capitan release date has been set to September 30, 2015. El Capitan is the name given...
Quote: Readers who are regular users of social media may have noticed a couple of hashtags popping up on Twitter over the past months — #ilooklikeanengineer and #thisiswhatanengineerlookslike. While Twitter...
Quote: In this Webinar Intel and MSC will explain how MSC Technologies is closing the gap between low-end and high-end Computer-On-Modules with a number of E3800-based products in the COM...
IS IT POSSIBLE TO INCREASE THE MECHANICAL ADVANTAGE OF TWO MATING SPUR GEAR TRAIN BY NOT CHANGING THEIR SIZE AND GEOMETRY