C Inetrview Question and Answer Set-8

| Thursday 9 June 2011

C Preprocessor

9.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.

9.2: I've got this tricky processing I want to do at compile time and I can't figure out a way to get cpp to do it.

Poor baby.

9.3: 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.

9.4: 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

9.5: 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.

0 comments:

Post a Comment

Popular Posts

Company Placement Papers

 

Copyright © 2010 All Question Papers Blogger Template by Dzignine