【发布时间】:2013-01-24 05:56:05
【问题描述】:
#include <stdio.h>
#define stringify(s) tostring(s)
#define tostring(s) #s
#define MAX_VALUE 65536
#define NUM 64 * 1024
enum {
MIN_VALUE = 1024,
};
int main(int argc, char *argv[])
{
const char *max_str = stringify(MAX_VALUE);
const char *min_str = stringify(MIN_VALUE);
printf("max = %s, min = %s\n", max_str, min_str);
return 0;
}
输出为“max = 65536, min = MIN_VALUE num = 1024 * 64” 专家,我怎样才能修改我的代码输出如下: 最大值 = 65536,最小值 = 1024 数量 = 65536
谢谢。
【问题讨论】:
-
MIN_VALUE 是
enum常量,不要宏。预处理器对此一无所知。 -
const char min_str[10]; snprintf(min_str, 9, "%d", MIN_VALUE);
标签: c string macros enums digital