Skip to content

Instantly share code, notes, and snippets.

@EteimZ
Created August 28, 2022 19:19
Show Gist options
  • Select an option

  • Save EteimZ/55fcf98ca473e2360fd0de22864a28db to your computer and use it in GitHub Desktop.

Select an option

Save EteimZ/55fcf98ca473e2360fd0de22864a28db to your computer and use it in GitHub Desktop.
Demonstrating C's type definition keyword
#include <stdio.h>
typedef struct point{
int x;
int y;
} Point;
typedef int length;
int main(){
Point p1 = {10, 20};
Point p2 = {40, 60};
length x = 100;
printf("Point1(%d, %d)\n", p1.x, p1.y);
printf("Point2(%d, %d)\n", p2.x, p2.y);
printf("Length is %d\n", x);
return 0;
}
// Output:
// Point1(10, 20)
// Point2(40, 60)
// Length is 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment