Skip to main content

Posts

Preprocessor Directives

In a C program, all lines that start with # are processed by preprocessor which is a special program invoked by the compiler. In a very basic term, preprocessor takes a C program and produces another C program without any # . There are 4 main types of preprocessor directives: Macros File Inclusion Conditional Compilation Other directives  All preprocessor commands begin with a hash symbol (#). It must be the first nonblank character, and for readability, a preprocessor directive should begin in the first column. The following section lists down all the important preprocessor directives Sr.No. Directive & Description 1   #define Substitutes a preprocessor macro. 2   #include Inserts a particular header from another file. 3   #undef Undefines a preprocessor macro. 4   #ifdef Returns true if this macro is defined. 5   #ifndef Returns true if this macro is not defined. 6   #if Tests if a compile time condition is true. 7   #else The alt

Introduction to C Programming

C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was first implemented on the DEC PDP-11 computer in 1972. The main features of C language include low-level access to memory, simple set of keywords, and clean style, these features make C language suitable for system programming like operating system or compiler development.Many later languages have borrowed syntax/features directly or indirectly from C language. Like syntax of Java, PHP, JavaScript and many other languages is mainly based on C language. C++ is nearly a superset of C language having object oriented features. Ken Thompson (left) with Dennis Ritchie (right, the inventor of the C programming language) In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K&R standard.When C was first written the standard was set by its authors Kernighan and Ritche - hen