在C语言中#define PRICE=30定义了与30等价的符号常量PRICE
在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
原文地址: https://www.cveoy.top/t/topic/ilJD 著作权归作者所有。请勿转载和采集!