jump to last post 1-3 of 3 discussions (4 posts)

How do we know to use a particular header file in C programming?

  1. Naveed Ahmed 624 profile image85
    Naveed Ahmed 624posted 3 years ago

    How do we know to use a particular header file in C programming?

    I am new to C Programming and I have observed that we can perform similar tasks while using either of the header files "iostream.h" and "stdio.h". Because functions such as "cout" and "cin" in "iostream.h" can perform similar tasks as can "printf" and "scanf" when we are using the header file "stdio.h".

    So how do we know which header file to use when? Is there a difference (in using particular header files and functions) when we are programming via different platforms i.e Dev C++, Microsoft Visual C++, Turbo C++ or different operating systems?

  2. WestelCS profile image61
    WestelCSposted 3 years ago

    A header file is a file containing C declarations and macro definitions to be shared between several source files. You request the use of a header file in your program by including it, with the C preprocessing directive `#include'.

    1. Naveed Ahmed 624 profile image85
      Naveed Ahmed 624posted 3 years agoin reply to this

      Could you please answer after reading the details of the question? I have not got the answer to what I needed.

  3. Naveed Ahmed 624 profile image85
    Naveed Ahmed 624posted 3 years ago

    I've myself got the answer to this question. Actually I started learning C Programming as a course in my studies, and having the wrong book led me into this confusion.

    The tutor was actually teaching C language on the C++ (Dev C++) platform whereas the book I had was "C How to Program". Therefore the difference in the use of the header files "iostream.h" and "stdio.h" as I've (now) found out from my tutor lies in that iostream.h is used in C++ while stdio.h in C programming.

 
working