News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

"C" Programming Language - C PreProcessor

Started by sivaji, Jan 10, 2008, 06:59 PM

Previous topic - Next topic

sivaji

Programming Stuffs in "C" - Technical Skills for INTERVIEW

C Preprocessor

1: How can I use a preprocessor #if expression to tell if a machine is big-endian or little-endian?

#ifdef __BIG_ENDIAN should work on all known machines; Borland defines it.

2: How can I list all of the pre-#defined identifiers?

#define __ALL_CPP_IDS - put this in a source file, and run it through your C preprocessor.

3: How can I write a cpp macro which takes a variable number of arguments?

Try something like this:
#define add(x) (x)
#define add(x, y) (x + y)
#pragma induction add

4: Shouldn't the following code:
   #define ROSE 1
   #define CHRYSANTHEMUM 2
   #define RHODODENDRON 3
   #define WATER_LILY 4
   printf("%d\n", CHRYSATHNEMUM);

print ``2''?

You misspelled CHRYSANTHEMUM. Use abbreviations for long flower names in C code.
Am now @ Chennai