Skip to content

Instantly share code, notes, and snippets.

@oknauta
Last active June 11, 2024 04:02
Show Gist options
  • Save oknauta/5d22de72fd7f6a1c0ffb786fe03fb84c to your computer and use it in GitHub Desktop.
Save oknauta/5d22de72fd7f6a1c0ffb786fe03fb84c to your computer and use it in GitHub Desktop.
Using `struct` to create an information.
/**************************************
* File: ford_car.c
* Date: 2024-06-11 | 2024-06-11
**************************************/
#include <stdio.h>
#define FORD_BRAND "Ford"
#define FORD_CAR_MODEL "F3310"
#define FORD_CAR_F3310_YEAR 2024
struct car
{
char *brand;
char *model;
unsigned short int year;
};
int main()
{
struct car ford_car =
{
.brand = FORD_BRAND,
.year = FORD_CAR_F3310_YEAR,
.model = FORD_CAR_MODEL
};
printf("Brand:\t%s\nModel:\t%s\nYear:\t%d\n", ford_car.brand, ford_car.model, ford_car.year);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment