typedef in C
Giving types shorter, clearer names.
typedef struct {
char name[32];
int score;
} Player;
typedef unsigned long ScoreID;
Player promote(Player p, int bonus) {
p.score += bonus;
return p;
}
How it works
- An anonymous struct plus
typedefnames itPlayer. typedefalso aliases a plain type likeunsigned long.- The alias reads like any other type.
Keywords and builtins used here
charintlongpromotereturnstructtypedefunsigned
The run, in numbers
- Lines
- 11
- Characters to type
- 153
- Tokens
- 41
- Three-star pace
- 95 tpm
At the three-star pace of 95 tokens a minute, this run takes about 26 seconds.
Step 3 of 3 in Structs, step 21 of 25 in Pointers & memory.