C Tutorial/Preprocessor/define — различия между версиями

Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 10:31, 25 мая 2010

Use #define to define constant

#include <stdio.h>
#define TRUE           1
#define FALSE          0
#define BS             "\b"
#define TAB            "\011"
main(){
   printf("%d",TRUE);
   printf("%d",FALSE);
   printf("%c",BS);
   printf("%d",TAB);
}
19

Use preprocessor to define integer and string

#include <stdio.h>
#define VAL 35
#define HELLO "HELLO"
main ()
{
    int res;
    res = VAL-5;
    printf ("res = VAL-5: res == %d\n", res);
    printf ("%s",HELLO);
}
res = VAL-5: res == 30
      HELLO