The C Preprocessor: The preprocessor provides facilities for including source code from other files (useful in separate compilation and when using library routine) and for doing conditional compilation (which is used frequently when writing portable code). It also provides a powerful macro facility, which can be very useful to declare symbolic constants. Any preprocessor command starts with pound sign ( # ) which forms the beginning of the preprocessor command. The carriage return forms the end of any preprocessor command. Now, we will consider only two of the C preprocessors' capabilities; text inclusion, and simple text substitution. Text inclusion: Look at this program: void main (void) printf("Hello World!\n"); Notice that the printf function has not been defined anywhere. The printf is part of a set function used for standard input and output. These functions are defined in a separate file known as the standard library. In order to use these functions correctly, a source code file requires information about their parameters and return type. This information is provided in a header file called stdio.h. All the information in the stdio.h can be brought into a source code file by use of a preprocessor include operation. #include

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter7: Developing An Excel Application
Section: Chapter Questions
Problem 4.13CP
icon
Related questions
Topic Video
Question

Please answer the question or example in the uploaded photos and please explain what is going on !

The C Preprocessor:
The preprocessor provides facilities for including source code from other files (useful in separate
compilation and when using library routine) and for doing conditional compilation (which is used
frequently when writing portable code). It also provides a powerful macro facility, which can be
very useful to declare symbolic constants.
Any preprocessor command starts with pound sign ( # ) which forms the beginning of the
preprocessor command. The carriage return forms the end of any preprocessor command. Now,
we will consider only two of the C preprocessors' capabilities; text inclusion, and simple text
substitution.
Text inclusion:
Look at this program:
void main (void)
{
printf("Hello World!\n");
}
Notice that the printf function has not been defined anywhere. The printf is part of a set function
used for standard input and output. These functions are defined in a separate file known as the
standard library. In order to use these functions correctly, a source code file requires information
about their parameters and return type. This information is provided in a header file called stdio.h.
All the information in the stdio.h can be brought into a source code file by use of a preprocessor
include operation.
#include <stdio.h>
The file name is stdio.h ( 'h’ for a 'h’eader file) and the fact it is surrounded by angle brackets
('<...>') indicates to the preprocessor that it is to search in the system "include file" directories to
find the header file. It is possible to create your own header files and include them.
Transcribed Image Text:The C Preprocessor: The preprocessor provides facilities for including source code from other files (useful in separate compilation and when using library routine) and for doing conditional compilation (which is used frequently when writing portable code). It also provides a powerful macro facility, which can be very useful to declare symbolic constants. Any preprocessor command starts with pound sign ( # ) which forms the beginning of the preprocessor command. The carriage return forms the end of any preprocessor command. Now, we will consider only two of the C preprocessors' capabilities; text inclusion, and simple text substitution. Text inclusion: Look at this program: void main (void) { printf("Hello World!\n"); } Notice that the printf function has not been defined anywhere. The printf is part of a set function used for standard input and output. These functions are defined in a separate file known as the standard library. In order to use these functions correctly, a source code file requires information about their parameters and return type. This information is provided in a header file called stdio.h. All the information in the stdio.h can be brought into a source code file by use of a preprocessor include operation. #include <stdio.h> The file name is stdio.h ( 'h’ for a 'h’eader file) and the fact it is surrounded by angle brackets ('<...>') indicates to the preprocessor that it is to search in the system "include file" directories to find the header file. It is possible to create your own header files and include them.
You can surround the header file by double quotes ( “.“),instead of angle brackets. In this case,
the preprocessor will search in the directory where it found the source file, which is including the
header file. If the header file is not found there, it will then search the system include file directories
as well.
Simple text substitution:
The preprocessor #define is used to do text substitution. It is important to always remember that
this is a very simple-minded facility, which simply replaces one text string where it finds an
occurrence of another. It is thus easy to get into trouble if you are not careful. The define command
consists of the define keyword, a define symbol, and a replacement text.
Example:
#define message "Hello world!\n"
int main()
{
printf(message);
}
When programming in C, mostly we make symbolic constants by using #define command. For
example
#define FALSE 0
#define TRUE
1
Notice that there are no semicolons at the end of the preprocessor statements. This is because they
are not statements. If you want to learn more about the C preprocessor see 'man cpp’.
Transcribed Image Text:You can surround the header file by double quotes ( “.“),instead of angle brackets. In this case, the preprocessor will search in the directory where it found the source file, which is including the header file. If the header file is not found there, it will then search the system include file directories as well. Simple text substitution: The preprocessor #define is used to do text substitution. It is important to always remember that this is a very simple-minded facility, which simply replaces one text string where it finds an occurrence of another. It is thus easy to get into trouble if you are not careful. The define command consists of the define keyword, a define symbol, and a replacement text. Example: #define message "Hello world!\n" int main() { printf(message); } When programming in C, mostly we make symbolic constants by using #define command. For example #define FALSE 0 #define TRUE 1 Notice that there are no semicolons at the end of the preprocessor statements. This is because they are not statements. If you want to learn more about the C preprocessor see 'man cpp’.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage