Name the header file to which following library functions belong
Answers
Answer:
C++ Header Files and Standard Functions
(This info is taken from Appendix C of the nice book Data Abstraction and Problem Solving with C++, 3rd ed., by F. M. Carrano & J.J. Prichard.)
Here is a list of commonly used C++ headers. If an older version of the header exists, its name is shown in parentheses.
cassert (assert.h)
This library contains only the function assert. You use
assert(assertion);
to test the validity of an assertion. If assertion is false, assert writes an error message and terminates program execution. You can disable all occurrences of assert in your program by placing the directive
#define NDEBUG
before the include directive.
cctype (ctype.h)
Most functions in this library classify a given ASCII character as a letter, a digit, and so on. Two other functions convert letters between uppercase and lowercase.
The classification functions return a true value if ch belongs to the specified group; otherwise they return false.
Answer:
ctype.h: It is a header file that contains character testing and conversion functions. For example isalpha (c) returns an int type data and determine if the argument c is alphabetic. It returns nonzero value if true; 0 otherwise. toascii(c ): is a conversion function defined in ctype.h that converts value of argument to ascii. (ii) string.h: It is also a standard header file that contains string manipulation funcions. For example strcmp(c1,c2) function compares two strings c1 and c2 lexicographically. It returns a negative value if c1c2.
Explanation:
Header Files : These are the files that are included at the top of any program. If we use any function inside a program, then the header file containing declaration or definition of that function ,has to be included.Like printf() is defined in stdio.h.
Library Files: These are the files which the compiler uses in order to define the functions which have been used in the program and had been declared inside the header file.Like, printf() has its complete definition ,like how it will work etc. in an I/O library!
Difference:
- Header files are TEXT files while library files are BINARY. This means, we can read and modify the header file but not the library!
- Header file is in C language while the library is in machine language!
- Header file has to be included by the programmer while the compiler automatically relates the library file(s) with the program!
- Generally, a header file notifies the compiler of certain things (mostly their existence or declarations) so that the compiler can correctly build a single translation unit (such as a single C file).
- A library file is the actual executable code that does the work as specified in that header file. This is linked in by the linker to provide the actual functionality (the _definitions rather than just the declarations).
- So, in your example, you may have the line:
- #include <pthread.h>
- which tells the compiler all about the existence of the pthread_mutex_this, pthread_condvar_that and pthread_thread_the_other stuff but doesn't actually provide the implementations of those things.
- The -lpthread option tells the linker that it should locate a library based on the pthread name from which it can pull in the actual implementations, in order to forn the final executable.
- Similarly, while stdio.h holds information about the I/O stuff, the actual code for it will be in the runtime library (though you rarely have to link that library specifically since the compiler will try to take care of it for you). Because you usually link with the compiler (i.e., the compiler invokes the linker for you), it knows that you're probably going to need the C run time library. If you were to use the linker directly (such as by using the ld command), that probably wouldn't happen, and you'd have to be explicit.
Reference Link
- https://brainly.in/question/17123712
- https://brainly.in/question/17182478