0% found this document useful (0 votes)
24 views4 pages

Standard Preprocessorpdf

The document explains the concept of a pre-processor in C programming, which operates before compilation and processes directives that start with '#'. It details types of pre-processor directives including file inclusion for standard and user-defined header files, as well as macros defined using the '#define' directive. Examples illustrate how to include libraries and define constants for use in the code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Standard Preprocessorpdf

The document explains the concept of a pre-processor in C programming, which operates before compilation and processes directives that start with '#'. It details types of pre-processor directives including file inclusion for standard and user-defined header files, as well as macros defined using the '#define' directive. Examples illustrate how to include libraries and define constants for use in the code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

STANDARD C PRE-PROCESSOR

What is Pre-Processor?
• Pre-processor is a program which performs before the
compilation.
source
file(.c) pre Pure linker/
HLL processor HLL compiler assembler
Object M/C loader EXE
code code FILE

• Pre-processor only notice # started statements.


• # is called as Pre-processor directive.
• The word after # is called as Pre-processor command.
Eg-#include , #define, #undef etc

This method is normally used to include standard library header files.


#include<header file> eg- #include<stdio.h>
Note- If header file is written inside < > compiler search in standard directory

#include “header file” eg- #include "cube.c"


Note- If header file is written inside " " compiler search in current directory
This method is normally used to include programmer-defined header files.
................................
................................
#include<stdio.h> add ................................
void main() ................................
{
printf("hello\n"); ................................
} void main()
qaz.c {
printf("hello\n");
}
qaz.i
Types of Pre-Processor directive
1. File Inclusion
2. Macros
3. Conditional Compilation

File Inclusion
This type of preprocessor directive tells the compiler to include a file in
the source code program. There are two types of files which can be
included by the user in the program.
Header File or Standard files: These files contains definition of pre-
defined functions like printf(), scanf() etc. These files must be included
for working with these functions. Different functions are declared in
different header files.

Syntax - #include<filename>
Eg- #include<stdio.h>

user defined files: When a program becomes very large, it is good


practice to divide it into smaller files and include whenever needed.
These types of files are user defined files.

Syntax- #include “ filename ”


Eg-#include “cube.c”
Macros-
The ‘#define’ directive is used to define a macro.
Syntax- #define symbolic constant value
Macros are a piece of code in a program which is given some
name.
Whenever this name is encountered by the compiler the
compiler replaces the name with the actual piece of code.
Note: There is no semi-colon(‘;’) at the end of macro definition.
Macro definitions do not need a semi-colon to end.
Eg- #include<stdio.h>
#define PI 3.14 macros

void main()
{
int radius,area;
printf(“enter radius to find area”);
scanf(“%d”,&radius);
area=PI*radius*radius;
printf(“area of circle is %d”,area);
}

You might also like