|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
1. 请补充下面代码,添加一个宏定义,让程序可以统计 COUNTS 参数的个数。
我用DEV有报错
D:\C语言程序设计与数据结构\S1E41\S1E41.cpp [Error] expected ')' before 'Apple'
是说说我缺少括号?但是我看也没少啊。代码也是参考答案,为什么会这样啊?
代码如下:
- #include <stdio.h>
- #define ARGUMENTS(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, ...) A11
- #define COUNTS(...) ARGUMENTS(FISHC, ## __VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
- int main(void)
- {
- printf("COUNTS()有 %d 个参数。\n", COUNTS());
- printf("COUNTS(1, 2, 3)有 %d 个参数\n", COUNTS(1, 2, 3));
- printf("COUNTS("Apple", "Banana", "Cat", "Dog")有 %d 个参数\n", COUNTS("Apple", "Banana", "Cat", "Dog"));
- return 0;
- }
复制代码
- printf("COUNTS()有 %d 个参数。\n", COUNTS());
- printf("COUNTS(1, 2, 3)有 %d 个参数\n", COUNTS(1, 2, 3));
- printf("COUNTS(""Apple"", ""Banana"", ""Cat"", ""Dog"")有 %d 个参数\n",COUNTS("Apple", "Banana", "Cat", "Dog") );
复制代码
|
|