codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C typedef

C typedef

Give a type a shorter name.

typedef removes the need to write struct each time.

Example code

#include <stdio.h>
typedef struct { int x, y; } Point;
int main() {
  Point p = {3, 4};
  printf("%d\n", p.x + p.y);
  return 0;
}

Run this code in the online editor

← C unionsC struct padding →