Adding Debug Statements with the Preprocessor - C Preprocessor

C examples for Preprocessor:Preprocessor Operators

Description

Adding Debug Statements with the Preprocessor

Demo Code

#include <stdio.h>

#define DEBUG/*from  w  ww .  j  a  va2 s. c  om*/

int process (int i, int j, int k){
    return i + j + k;
}

int main (void){
    int i, j, k, nread;

    nread = scanf ("%d %d %d", &i, &j, &k);

#ifdef DEBUG
    fprintf (stderr, "Number of integers read = %i\n", nread);
    fprintf (stderr, "i = %i, j = %i, k = %i\n",i ,j ,k);
#endif

    printf ("%i\n", process (i, j, k));
    return 0;
}

Result


Related Tutorials