C Tutorial/Preprocessor/ifdef

Материал из C\C++ эксперт
Перейти к: навигация, поиск

ifdef

The ifdef directive makes substitutions based on whether a particular identifier is defined.


<source lang="cpp">#define USA 1 // #define EUP 1

  1. include <stdio.h>
  2. ifdef USA
  3. define currency_rate 46
  4. endif
  5. ifdef EUP
  6. define currency_rate 100
  7. endif

main() {

   int rs;
   rs = 10 * currency_rate;
   printf ("%d\n", rs);

}</source>

460