Created
August 28, 2022 19:19
-
-
Save EteimZ/55fcf98ca473e2360fd0de22864a28db to your computer and use it in GitHub Desktop.
Demonstrating C's type definition keyword
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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