Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

C Tutorial
Introduction to C Programming
Variables in C
Opertaors in C
Branching Statement in C
Looping Statement in C
C Storage Class
Functions in C
The C Preprocessor
Input/Output Functions in C
File I/O Functions in C
Pointers in C
Arrays in C
Dynamic Memory Allocation in C
Strings in C
Structures in C

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


The C Preprocessor
Previous Next


  • The C Preprocessor is a separate step in the compilation process, but not part of the compiler.


  • C Preprocessor is just a text substitution tool and we'll refer to the C Preprocessor as the CPP.



The C Preprocessor

  • All preprocessor lines always begin with #. This listing is from Weiss pg. 104. The unconditional directives are as follows:
    • #define - Define a preprocessor macro
    • #include - Insert a particular header from another file
    • #undef - Undefine a preprocessor macro
    The conditional directives are as follows:
    • #ifndef - If this macro is not defined
    • #ifdef - If this macro is defined
    • #if - Test if a compile time condition is true
    • #elif - #else an #if in one statement
    • #else - The alternative for #if
    • #endif - End preprocessor conditional
    Other directives include:
    • ## - Token merge, creates a single token from two adjacent ones
    • # - Stringization, replaces a macro parameter with a string constant




Some examples of the above is given below:
#define MAX_ARRAY_LENGTH 20

The above code will tell the CPP to replace instances of MAX_ARRAY_LENGTH with 20. To increase readability,use #define for constants.




#include <stdio.h>
#include "mystring.h"

The above code tells the CPP to get stdio.h from System Libraries and add the text to this file. The next line tells CPP to get mystring.h from the local directory and then add the text to the file.




#undef MEANING_OF_LIFE
#define MEANING_OF_LIFE 42

The above code tells the CPP to undefine MEANING_OF_LIFE and define it for 42.




#ifndef IROCK
#define IROCK "You wish!"
#endif

The above code tells the CPP to define IROCK only if IROCK isn't defined already.




#ifdef DEBUG
/* Your debugging statements here */
#endif

Thed above code tells the CPP to do the following statements if DEBUG is defined.If you pass the -DDEBUG flag to gcc,this is useful .




Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previous Next

Keywords: The C Preprocessor, visual studio preprocessor, c define, define preprocessor, if preprocessor, preprocessor ifdef, gnu preprocessor, printf c, c pointers, sprintf c, c tutorial, c arrays, fortran preprocessor, preprocessor string, c syntax, c array, c string, void c, preprocessor definition, the c library


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.