小编Sun*_*pta的帖子

为什么当MACRO没有任何内存位置时,sizeof(MACRO)会给出4字节的输出?

以下是小程序:

#include <stdio.h>
#define max 'A'

int main()
{
    char a;
    printf("max[%d] sizeof[max][%ld]\n", max, sizeof(max));
    a = max;
    printf("a[%d] sizeof[a][%ld]\n", a, sizeof(a));
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

该计划的输出是:

max[65] sizeof[max][4]
a[65] sizeof[a][1]
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我理解为什么sizeof(max)是4个字节?

c macros c-preprocessor

8
推荐指数
1
解决办法
154
查看次数

标签 统计

c ×1

c-preprocessor ×1

macros ×1