C语言符号常量定义:#define PRICE 30 - 详解及示例
在C语言中,符号常量的定义应该是不包含等号的,应该写成`#define PRICE 30`。这样定义的符号常量`PRICE`的值为30,可以在程序中直接使用`PRICE`代表30。例如:
#include <stdio.h>
#define PRICE 30
int main() {
int quantity = 5;
int total = PRICE * quantity;
printf("Total cost: %d\n", total);
return 0;
}
输出结果为:
Total cost: 150

原文地址: http://www.cveoy.top/t/topic/p3L8 著作权归作者所有。请勿转载和采集!