Programs are divided into modules or functions. Some functions are written by programmers such as you. Others are stored in the C library and can be accessed by you. If you want to access library functions, it is necessary to give the C compiler information about the functions to be accessed. At this time, I will not go into the details. However, I can tell you that the file named stdio.h (which is included with the C compiler and is called a header file) contains information about the library function, printf, used in the program below.
#include
void main()
{
printf("This is C!");
}
The directive #include tells the preprocessor portion of the C compiler (meaning the part of the compiler that performs actions prior to the translation of the code into machine language instructions) to attach the stdio.h file to the file with the source code. Because the line of code, #include causes the preprocessor to act, it is called a preprocessor directive. We use, at most, only a few preprocessor directives for each program that we write. Therefore, writing preprocessor directives will not be a major part of the programming process for us.
No comments:
Post a Comment