如何在C中打印枚举?

时间:2016-09-28 10:33:16

标签: c enums

我有enum constucttypedef struct

#define str(x) #x

typedef enum {
    MCSIMULATION,
} jobType;

typedef struct {
    jobType type;
}x, *xPtr;

int main(){
    xPtr f = malloc(sizeof(x));
    f->type = MCSIMULATION;
    return 0;
}

然后我要打印f.type

的值
printf("%s", str(f->type));

但是作为我的输出,当我期望有" MCSIMULATION":

f->type

如何正确打印?

0 个答案:

没有答案