Why should we typedef a struct so often in C?

后端 未结 15 2928
無奈伤痛
無奈伤痛 2020-11-21 23:58

I have seen many programs consisting of structures like the one below

typedef struct 
{
    int i;
    char k;
} elem;

elem user;

Why is i

15条回答
  •  遥遥无期
    2020-11-22 00:24

    Turns out in C99 typedef is required. It is outdated, but a lot of tools (ala HackRank) use c99 as its pure C implementation. And typedef is required there.

    I'm not saying they should change (maybe have two C options) if the requirement changed, those of us studing for interviews on the site would be SOL.

提交回复
热议问题