C Slides
C Slides
Introduction
Its an offspring of Basic combined programming called B which was developed by Ken Thomson
B language was interpreter-based but it was very slow So Dennis Ritchie modified the B language and named it as C
History
1960
1967 ALGOL BCPL
International Group
Martin Richards
1970
B Traditional C
1972
1978
K&R
1989
ANSI C
ANSI Committee
1990
ANSI/ISO C
ISO Committee
Benefits
C programs are efficient, fast & Highly portable It can be written in one computer and can be run in another computer without any Modification.
Its easy for debugging, testing & maintenance because of structured programming
COMPILER
A compiler is a computer program (or set of programs) that transforms source code written in a computer language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program. The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code). A program that translates from a low level language to a higher level one is a decompiler. A program that translates between high-level languages is usually called a language translator,
Why
C used Widely
by a name
ABOUT PRINTF:
Printf The printf statement allows you to send output to standard out. Here is program that will help you learn more about printf: #include <stdio.h> int main() { int a, b, c; a = 5; b = 7; c = a + b; printf("%d + %d = %d\n", a, b, c); return 0; }
ABOUT SCANF:
The scanf function allows you to accept input from standard in, which for us is generally the keyboard.
{
int a, b, c;
Simple Programs
# include <stdio.h> # include <conio.h> Void main() { /*Program to Display The Content*/ clrscr(); printf(Good Morning..! Have a Nice Day); getch(); }
Simple Programs
# include <stdio.h>
# include <conio.h>
Void main()
{
/*Program for Addition*/ int a,b,c;
clrscr();
printf(Enter the value of A :);
scanf(%d,&a);
printf(Enter the value of B :);
scanf(%d,&b);
c=a+b; printf(The Value of C is :,c);
Character Set
The Character that can be used to form words, numbers and expression depends upon the computer on which the program runs. Letters Digits Special Character White Space
, .
.Comma .Period
& ^
.Ampersand .Caret
;
: ? ' " ! |
.Semicolon
.Colon .Question Mark .Aphostrophe .Quotation Marks .Exclaimation Mark .Vertical Bar
*
+ < > ( )
.Asterisk
.Minus Sign .Plus Sign .Opening Angle (Less than sign) .Closing Angle (Greater than sign) .Left Parenthesis .Right Parenthesis
/
\ ~ -
.Slash
.Backslash .Tilde .Underscore
[
] { }
.Left Bracket
.Right Bracket .Left Brace .Right Bracket
$
%
.Dollar Sign
.Percentage Sign
#
.
.Number Sign
.
Keywords
Keywords are words that have special meaning to the C compiler. These keywords cannot be used as identifiers in the program
auto
double
int
struct
break
else
long
switch
case
enum
register
typedef
char
extern
return
union
const
float
short
unsigned
continue
for
signed
void
default
go to
size of
volatile
do
if
static
while
Identifiers
Identifiers" are the names you supply for variables, types, functions, and labels in your program. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Rules: First character must be an alphabet (or underscore). Must consist of only letters, digits or underscore. Only first 31 characters are significant. Cannot use a keyword. Must not contain white space .
Constants
Constants
Numeric Constants
Character Constants
Integer
Real
Single Character
String
Data Types
This enables the programmer to select the appropriate data type as per the need of the application ANSI C supports three classes of data types
Data Type
Bytes
Default Range
signed char
-128 to 127
Unsigned char
0 to 255
-32768 to 32767
0 to 65535
-2147483648 to 2147483647
0 to 4294967295
Float
-3.4e38 to +3.4e38
Double
-1.7e308 to +1.7e308
long double
10
-1.7e4932 to +1.7e493
2.
3.
4.
5.
6.
7. 8.
Arithmetic operators (+,-,*,/,%) Relational operators (>,<,= =,>=,<=,!=) Logical operators (&&,||,!) Increment and decrement operator (++,--) Assignment operator (=) Bitwise operator (&,|,^,>>,<<) Comma operator (,) Conditional operator (?,:)
Operator Precedence
Operator Description Parentheses (function call) (see Note 1) Brackets (array subscript) Member selection via object name Member selection via pointer Postfix increment/decrement (see Note 2) Prefix increment/decrement Unary plus/minus Logical negation/bitwise complement Cast (change type) Dereference Address Determine size in bytes Multiplication/division/modulus Associativity left-to-right () [] . -> ++ --
right-to-left
left-to-right left-to-right
left-to-right left-to-right
+ << >>
< <= > >=
== != & ^ | &&
Relational is equal to/is not equal to Bitwise AND Bitwise exclusive OR Bitwise inclusive OR Logical AND
left-to-right left-to-right
left-to-right
left-to-right left-to-right
||
?:
Logical OR
Ternary conditional Assignment Addition/subtraction assignment Multiplication/division assignment Modulus/bitwise AND assignment Bitwise exclusive/inclusive OR assignment Bitwise shift left/right assignment Comma (separate expressions)
left-to-right
right-to-left
right-to-left
= += *= %= ^= <<=
-= /= &= |= >>=
left-to-right
\o Octal constant
\r Carriage return, no line feed,
%c a single character, char %d a decimal number, int , %hd is for short %ld is for long %e a floating point number, float in scientific notation, %E for 1.0E-3 %le is for double, %Le is for long double
%f a floating point number with decimal point %10.4f 10 wide .dddd %lf is for double, %Lf is for long double %g a floating point number, %f or %e as needed, %G for capital E %lg is
for double, %Lg is for long double
PREPROCESSOR DIRECTIVES:
Decision Statement
To alter the flow of a program. Test the logical conditions. Control the flow of execution as per the selection.
If-Construct
Syntax: i) if (expr) statement; ii) if(expr) { statement1; statement2; }
If-else Construct
Syntax: if (expr) statement1; else statement2; Example: a=5,b=10 if (a<b) { printf(b is bigger than a); } else { Printf(a is bigger than b); }
Else-if Construct
Syntax: if (expr) Statement 1; else if(expr1) Statement 2; else if(exp2) Statement 3; else Statement n; Example: a=5 b=10 c=15 If (a>b && a>c) { printf (a is the biggest no); } else if (b>c) { printf(b is the biggest no); } else { Printf(c is the biggest no); }
Nested if Construct
i)
If(expr) { if(expr2) statement 1; }
ii) If(expr) { if(expr1) statement1; else statement2; } else { if(expr2) statement3; else if(expr3) statement4; else statement5; }
If(a>b) { if(a>c) { printf(a is the biggest no); } else { printf(c is the biggest no); } } Else if(b>c) { printf(b is the biggest no); } Else { printf(c is the biggest no); }
evencount = oddcount = 0; if ( (num % 2) == 0 ) { printf(%d is an even number.\n, num); ++evencount; if( (num % 4) == 0 ) printf(It is divisible by 4\n); if( num == 0 ) { printf(It is zero.\n); printf(That isnt interesting.\n); } } else { printf(%d is an odd number.\n, num); ++oddcount; if( (num % 9) == 0 ) printf(It is divisible by 9\n); else printf(It is not divisible by 9\n); }
Switch Construct
Syntax: switch (expr) /* expr is a boolean expression { case C1: {statement0;break;} case C2: {statement1;break;} default: /* optional */ {DefaultStatement;break;} } Note : C1 & C2 represent values. It is the type of int or char only.
Types
while-statement do-while statement for-statement
While Constructs
Syntax: while(expr) { statement1; statement2; }
True Boolean values are any integer different from zero; False Boolean value is the integer zero.
{
printf(precision\n); i++; }
{
int counter, howmuch; scanf("%d", &howmuch); counter = 0;
counter++;
printf("%d\n", counter);
}
return 0; }
Do-while Construct
Syntax: do { statement1; statement2; }while(expr);
Note: while statement executes zero or more iterations of the loop; do-while statement executes one or more iterations of the loop.
For Construct
Syntax: for(expr1; expr2; expr3) Statement; for(expr1;expr2;expr3) { statement1; statement2; }
Break statement
Syntax: break;
Semantic: terminates the execution of a loop or a switch
Continue statement
Syntax: continue;
Array
One-Dimensional Array
collection of elements of same data type that are stored contiguous in memory.
data
10
20
30
25
35
50
45
28
14
1000 1002
1010 1012
1014 1016
1018
Address
One-Dimensional Array
The subscript, or the index of each array element is determined based on the number of offset positions it is from the starting position. The starting offset is taken as 0.
offset
0
10
1
20
2
30
3
25
4
35
5
6
6
50
7
45
8
28
9
14
1000 1002
1010 1012
1014 1016
1018
One-Dimensional Array
Syntax:
Example:
int a[10]; block of 10 contiguous elements in memory.
a
offset
a[0]
a[1]
a[2]
a[3] a[4]
a[5] a[6]
a[7] a[8]
a[9]
One-Dimensional Array
Initialization
A character array needs a string terminator, the NULL character (\0) as the last character, whereas integer and float arrays do not need a terminator. Examples:
char array1[ ] = {A, R, R, A, Y, \0}; char array2[ ] = {ARRAY}; char dayofweek[7] = {M, T, W, T, F, S, S};
Initialization
Example:
One-Dimensional Array
int i = 0;
printf( String 1 is %s\n, array1); printf( String 2 is %s\n, array2); }
One-Dimensional Array
Initialization
int a[5]={7,3,8,2,25}; (or) int a[5]; a[0]=7; a[1]=3; a[2]=8; a[3]=2; a[4]=25;
Input To Array
Normal Variable:
Array Variable:
int a[20],i; for(i=0;i<20;i++) { scanf(%d, &a[ i ]); }
int a; scanf(%d,&a);
Array Variable: int a[20]; scanf(%d,&a[0]); ----scanf(%d,&a[19]);
4 lines
gets(string);
buffer) */
fflush( stdin);
for(i =0; string[i] != \0; i = i + 1); printf(The length of the string is %d \n, i);
}
Array Addressing
In the declaration: char string[11]; the name of the array refers to the starting address of the area that gets allocated for storing the elements of the array.
Thus, string contains the address of string[0]. In the aforesaid declaration, string refers to the starting position of the array, and the subscript refers to the offset position from the starting position.
Array Addressing
string
100
100
101
102
103
104
105
106
107
108
109
110
a
0
b
1
c
2
d
3
e
4
f
5
g
6
h
7
i
8
j
9
\0
10
Array Addressing
To arrive at the address of the particular element, the compiler applies the following simple formula:
One-Dimensional Array
Example: #include <stdio.h> int main() { int iMarks[4]; short newMarks[4]; iMarks[0]=78; iMarks[1]=64; iMarks[2]=66; iMarks[3]=74; for(i=0; i<4; i++) newMarks[i]=iMarks[i];
Two-Dimensional Array
Syntax:
datatype variablename [rowsize] [columnsize];
Address
Of a[0][0]
0
1 2 3 a[0][2] 1004
Two-Dimensional Array
Initialization
Example:
int array1[ 2 ][ 3 ] = { { 1, 2, 3 }, { 4, 5, 6 } }; int array2[ 2 ][ 3 ] = { 1, 2, 3, 4, 5 };
Two-Dimensional Array
Initialization
Example: #include <stdio.h> #include <conio.h> void main() { char arr[3][12]= { "Rose", "India", "technologies" }; clrscr(); printf("Array of String is = %s,%s,%s\n", arr[0], arr[1], arr[2]); getch(); }
int a[20],i;
for(i=0;i<20;i++) { scanf(%d, &a[ i ]); }
int a[10][5],i,j;
for(i=0;i<10;i++) { for(j=0;j<5;j++) { scanf(%d,&a[i][j]); } }
Note:
In this 2-D array example we will get input row by row. That means get rows value one by one using inner for loop. Increment row using outer loop.
Example: main ( ) { int stud [4] [3]; int i, j; for (i =0; i < =3; i ++) { for(j=0;j<=2;j++) { printf ("\n Enter roll no. and marks"); scanf ("%d%d", &stud [i] [j], &stud [i] [j] ); } }
for (i = 0; i < = 3; i ++) { for(j=0;j<=2;j++) { printf ("\n %d %d", stud [i] [j], stud [i] [j]); } }
Two-Dimensional Array
Functions
A function is a sub-program of one or more statements that performs a special task when called C supports two types of function
Library Function
User Defined Function
main()
{ -------
abc(x,y,z);
-------
}
abc(l,k,j) Function Definition (Formal argument)
{ }
-------------
Functions
A function is a sub-program of one or more statements that performs a special task when called
C supports two types of function
Library Function
User Defined Function
A function is declared as
Variables can be declared inside blocks Functions can not be defined inside other functions
Returning control
Example
#include<stdio.h> Void display() /* function declaration*/ Void main() { display();/*function call*/ } Void display()/*function definition*/ { int a,b,c; a=10;b=20; c=a+b; printf(%d,c); }
Key Points
A function gets called when the function name is followed by a semicolon. For example, main( ) { argentina( ) ; }
A function is defined when function name is followed by a pair of braces in which one or more statements may be present. argentina( ) { statement 1 ; statement 2 ; statement 3 ; }
For example,
Any function can be called from any other function. Even main( ) can be called from other functions. For example, main() { message( ) ; }
For example, main( ) { message( ) ; message( ) ; } message( ) { printf ( "\n Hai Welcome to C Language !!" ) ; }
Advantages of Functions
Manageable program development Use existing functions as building blocks for new programs
Software reusability
Types of functions
There are mainly 4 types of functions 1.Function with no arguments and no return values 2.Functions with arguments and no return values 3.Functions without arguments and no return values 4. Functions with arguments and return values
Invoking functions
Function can be be invoked by using two ways 1.Call by value 2.call by reference
Call by value
If a function is invoked by passing values of actual arguments to is corresponding formal arguments. Whenever using call by value, the values of actual arguments is copied into its corresponding formal arguments
Whenever we make changes in formal arguments which will not reflect to its corresponding actual arguments.
Example
#include<stdio.h> Void exchange(int a,int b) { int t; t=a; a=b; b=t; printf(the values of a and b are:%d%d,a,b); } Main() { int a,b; a=10;b=20; exchange(a,b);/* call by value procedure*/ }
2. Call by reference
If a function is invoked by passing the address of actual arguments to its corresponding formal arguments. If we make changes in the formal arguments ,all the values will reflected into its corresponding actual arguments.
Example
#include<stdio.h> Void exchange(int *a,int *b) { int t; t=*a; *a=*b; *b=t; printf(the values of a and b are:%d%d,*a,*b); } Main() { int a,b; a=10;b=20; exchange(&a,&b);/* call by reference procedure*/ }
Function Prototype
Function name Parameters what the function takes in Return type data type function returns (default int)
Used to validate functions Prototype only needed if function definition comes after use in program The function with the prototype
Recursion Function
Example: int main() { int result, number; ... result = factorial( number ); } int factorial( int num ) /* Function definition */ { ... if ( ( num > 0 ) || ( num <= 10 ) ) return( num * factorial( num - 1 ) ); /*call itself */ }
Structures
A structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling. Structures help to organize complicated data, particularly in large programs, because they permit a group of related variables to be treated as a unit instead of as separate entities. An example of a structure is the payroll record: an employee is described by a set of attributes such as name, address, social security number, salary, etc.
Declaring a Structure
The C language provides the struct keyword for declaring a structure. The following is a structure declaration for employee attributes.
struct empdata
{ int empno; char name[10]; char job[10]; float salary; };
Or a structure can be declared separately as: struct empdata emprec;/* emprec is a variable of structure type empdata */
Once a structure variable has been declared, the individual members of the structure can be accessed by prefixing the structure variable to the element of the structure.
struct empdata { int empno; char name[10]; char job[10]; float salary; } struct empdata emprec; emprec.empno=101; /* referring to the element of the structure variable emprec */
Structure Example
#include< stdio.h > void main() { struct { int id_no; char name[20]; char address[20]; int age; }newstudent; printf(Enter the student information); printf(Now Enter the student id_no); scanf(%d,&newstudent.id_no); printf(Enter the name of the student); scanf(%s,&new student.name); printf(Enter the address of the student); scanf(%s,&new student.address);
Initializing of a structure
struct empdata
{
int empno; char name[10];
char job[10];
float salary;
}emprec={101,Arun,Developer,20000};
Array of Structures
Just as it is possible to declare arrays of primitive data types, it should also be possible to declare arrays of structures as well. Consider the structure declaration for the employee details used earlier.
struct empdata
{
int empno;
char name[10]; char job[10]; float salary; };
Structure Example
#include< stdio.h > { struct info { int id_no; char name[20]; char address[20]; char combination[3]; int age; } struct info std[100]; int I,n; printf(Enter the number of students); scanf(%d,&n); printf( Enter Id_no,name address combination age\m); for(I=0;I < n;I++) scanf(%d%s%s%s%d,&std[I].id_no,std[I].name,std[I].address,std[I].combin ation,&std[I].age); printf(\n Student information); for (I=0;I< n;I++) printf(%d%s%s%s%d\n, ,std[I].id_no,std[I].name,std[I].address,std[I].combination,std[I].age); }
A structure may be defined as a member of another structure. In such structures the declaration of the embedded structure must appear before the declarations of other structures.
struct date { int day; int month; int year; }; struct student { int id_no; char name[20]; char address[20]; char combination[3]; int age; structure date def; structure date doa; }oldstudent, newstudent;
Consider a situation where your application needs to read records from a file for processing. The general approach would be to read the various fields of a record into corresponding memory variables.
Computations can then be performed on these memory variables, the contents of which can then be updated to the file.
But, this approach would involve manipulating the current file offset for the relevant fields that need to be updated.
The following statement writes the structure variable salesvar on to a file SALES.DAT, which is pointed to by the FILE type pointer fp:
fwrite( &salesvar, sizeof(struct salesdata), 1, fp);
Records can be read from a file using fread( ). The corresponding read statement using fread( ) for the earlier fwrite( ) statement would be: fread(&salesvar, sizeof(struct salesdata), 1, fp); Here, the first parameter &salesvar is the address of the structure variable salesvar into which 1 record is to be read from the file pointed to by the FILE type pointer fp. The second parameter specifies the size of the data to be read into the structure variable.
The pointer variable also should be the variable for the structure data type;
#include<stdio.h> struct student { int rollno; int marks; }s={101,99},*p;
With pointers, though, in accessing structure members an arrow notation is used, rather than the dot notation:
struct student { int rollno; int marks; }s={101,99},*p; main() { p=&s; printf("%d",p->rollno); printf("%d",p->rollno); getch(); }
Pointers
Pointers is a memory variable that stores a memory address It always denoted by (*) asterisk symbol
Features
Pointers save the memory space. Direct access to memory location Useful for representing two-dimensional & Multi- dimensional array
Declaration
int *x; float *f;
Pointers
Pointers are variables that contain memory addresses as their values. A variable name directly references a value. A pointer indirectly references a value. Referencing a value through a pointer is called indirection. A pointer variable must be declared before it can be used.
Contents1
* * *
ADDR11 Contents11
* *
ADDR16 Contents16
Example:
Pointer variable
#include <stdio.h> int main ( ) { int *aptr ; */ float *bptr ; float */ int a =10; float b =2.5f;
aptr
1000 10
a
1000
bptr
1500
b
2.5
1500
& -- "address operator" which gives or produces the memory address of a data variable * -- "dereferencing operator" which provides the contents in the memory location specified by a pointer
Pointer variables can be used in comparisons, but usually only in a comparison to NULL.
When an integer is added to or subtracted from a pointer, the new pointer value is changed by the integer times the number of bytes in the data variable the pointer is pointing to.
For example, if the pointer valptr contains the address of a double precision variable and that address is 234567870, then the statement: valptr = valptr + 2; would change valptr to 234567886
2.5
a++;
Pointer to arrays
An array is actually very much like pointer. We can declare the arrays first element as a[0] or as int *a because a[0] is an address and *a is also an address the form of declaration is equivalent. The difference is pointer is a variable and can appear on the left of the assignment operator that is lvalue. The array name is constant and cannot appear as the left side of assignment operator.
Pointer to arrays
/* A program to display the contents of array using pointer*/ main() { int a[100]; int i,j,n; printf(\nEnter the elements of the array\n); scanf(%d,&n); printf(Enter the array elements); for(I=0;I< n;I++) scanf(%d,&a[I]); printf(Array element are); for(ptr=a,ptr< (a+n);ptr++) printf(Value of a[%d]=%d stored at address %u,j+=,*ptr,ptr); } Strings are characters arrays and here last element is \0 arrays and pointers to char arrays can be used to perform a number of string functions.
File I/O in C
Files in C
A file must first be opened properly before it can be accessed for reading or writing. When a file is opened, a stream is associated with the file.
Successfully opening a file returns a pointer to (i.e., the address of) a file structure, which contains a file descriptor and a file control block.
Files in C
The statement: FILE *fp1, *fp2 ; declares that fptr1 and fptr2 are pointer variables of type FILE. They will be assigned the address of a file descriptor, that is, an area of memory that will be associated with an input or output stream. Whenever you are to read from or write to the file, you must first open the file and assign the address of its file descriptor (or structure) to the file pointer variable.
Opening Files
Syntax:
The statement: fp1 = fopen ( "mydata", "r" ) ; would open the file mydata for input (reading).
Opening Files
The statement: fp = fopen ("results", "w" ) ; would open the file results for output (writing).
Once the files are open, they stay open until you close them or end the program (which will close all files.)
If the file was not able to be opened, then the value returned by the fopen routine is NULL. For example, let's assume that the file mydata does not exist. Then: FILE *fptr1 ; fptr1 = fopen ( "mydata", "r") ; if (fptr1 == NULL) { printf ("File 'mydata' did not open.\n") ; }
Open Mode
"r Open text file for reading only "w Truncate to 0 length, if existent, or create text file for writing only. "a Append; open or create text file only for writing at end of file "r+ Open text file for update (reading and writing) "w+ Truncate to 0 length, if existent, or create text file for update "a+ Append; open or create text file for update, writing at end of file
fopen()
Creates a new file for use Opens a new existing file for use
Closes a file which has been opened for use
Fclose()
getc()
putc()
fscanf()
getw()
putw()
ftell()
rewind()
fclose(f1); /*close the file input*/ printf(\nData output\n); f1=fopen(INPUT,r); /*Reopen the file input*/ while((c=getc(f1))!=EOF) printf(%c,c); fclose(f1);
int a, b ; FILE *fptr1, *fptr2 ; fptr1 = fopen ( "mydata", "r" ) ; fscanf ( fptr1, "%d%d", &a, &b) ; the fscanf function would read values from the file "pointed" to by fptr1 and assign those values to a and b.
End of File
The end-of-file indicator informs the program when there are no more data (no more bytes) to be processed. There are a number of ways to test for the end-offile condition. One is to use the feof function which returns a true or false condition:
End of File
There are a number of ways to test for the end-offile condition. Another way is to use the value returned by the fscanf function: int istatus ; istatus = fscanf (fptr1, "%d", &var) ; if ( istatus == EOF ) { printf ("End-of-file encountered.\n) ; }
Writing To Files
Likewise in a similar way, in the following segment of C language code: int a = 5, b = 20 ; FILE *fptr2 ; fptr2 = fopen ( "results", "w" ) ; fprintf ( fptr2, "%d %d\n", a, b ) ; the fprintf functions would write the values stored in a and b to the file "pointed" to by fptr2.
Closing Files
The statements: fclose ( fptr1 ) ; fclose ( fptr2 ) ; will close the files and release the file descriptor space and I/O buffer memory.
printf ("%6.2f%2d%5.2f\n", a, b, c) ; printf ("%6.2f,%2d,%5.2f\n", e, f, g) ; } 12345678901234567890 **************************** 13.72 5 6.68 13.72, 5, 6.68
fseek()
int fseek ( Stream, Offset, Whence);
where stream -- file pointer offset -- no of position in bytes whence from position
**whence must be one of the values 0, 1, or 2 Whence value: 0 Beginning of the file 1 Current position 2 End of the file.
Rewind():
Pre Processing
in
C
Pre Processing
Refers before compiling the c program. Loads the template before compiling. Syntax #Macro Template Macro Expansion
Types of Macros
Defining Macros File Inclusion Conditional Macros Special cases
Defining Macros
#define <Label>(parameterlist)<Expansion> main() { . <Label> }
Defining Macros
Example: #include <stdio.h> #define PI 3.14 #define AREA(radius) (PI*radius*radius) main() { float areas[3]={AREA(1),AREA(2),AREA(3)}; int count; for (count=0; count <3; count++) { printf("Circle area=%f\n",areas[count]); } return 0; }
File Inclusion
#include<file name> (or) #include filename main() { .. .. }
Conditional Macros
Syntax: #ifdef MACRO controlled text #endif /* MACRO */
Conditional Macros
Syntax:
#if expression
text-if-true
#if X == 1 ... #elif X == 2 ... #else /* X != 2 and X != 1*/ ... #endif /* X != 2 and X != 1*/
Thank You.