what 's mean by wring " include ,, etc" at beginning of in C language?
2015-07-31 06:57:27 UTC
what 's mean by wring " include ,, etc" at beginning of in C language?
Three answers:
_Object
2015-07-31 09:36:58 UTC
# include
Instructs the C preprocessor to insert the contents of the header file "stdio.h" into the translation unit at the point you write that line.
Basically, the preprocessor takes the file "stdio.h", and replaces the line
# include
With the contents of stdio.h.
The file is the "STanDard IO (.) Header", so it contains the declaration of functions relating to input and output.
This is what allows you to write `printf' and such without getting errors relating to undeclared identifiers.
The definition belongs to the C library, but the corresponding header makes it usable in your source code: the declaration is a promise to the compiler that the function definition is somewhere else available to the linker (in this case, in the C runtime library).
# include
does about the same thing, except instead of inserting the contents of "stdio.h", it inserts the contents of "stdlib.h", which is the "STanDard LIBrary (.) Header" --- it's a collection of so-called "general utilities", and lets you write `malloc' and such without collecting error messages.
It's probably worth knowing that there's two ways to write that:
Both angle-brackets
# include
and double quotes
# include "header-file"
mean almost the same thing -- but there is a small difference.
When searching for the file inside brackets, the preprocessor searches system files first -- e.g., straight to the system header directories (which the preprocessor knows by default per it's configuration, or it's arguments), and then to the local directory --- but when searching for the filename inside quotes, the preprocessor searches local directories first, than system directories. It's dumb, I guess, but the rule is that
"Local headers go in quotes, system headers go in angle-brackets."
In certain ridiculous cases, this might bite you, so best do it right and avoid the bug.
Richard J
2015-07-31 08:23:10 UTC
When you program in C, it doesn't automatically have printf and scanf. In order to use it you need to use the library called "stdio.h "
Basically it is "standard input output.header" as it's the header file for input (scanf) and output (printf).
"stdlib.h" is the standard library. I'm not sure what functions you likely use from it as I generally code in C++, but I use it when I want to use rand().
The "#" beginning the line is a way to tell the compiler to do something such as to use those header files/libraries.
Sadsongs
2015-07-31 07:32:48 UTC
They're two of a small set of standard (system) libraries, giving access to basic input/output functions etc.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.