That's a touch specific, I think. So lets pull it back a level. What's a structure?
A structure is essentially a data object that bundles variables together. So, lets make one, I'm on an environmentally friendly kick and can't afford a Tesla so:
typedef struct bicycle { //We're making a struct called 'bicycle'
char* brand; //The brand of our bike.
int wheels; //Some of us still need training wheels, okay?
} bike; //What on earth didn't we already call this a bicycle? What's going on?
Alright, so lets stop for a moment and look at what we've done. First we've declared a struct 'bicycle' which is a bucket for two variables: a char* and an int by the names of brand and wheels respectively. 'bicycle' lives in the 'struct' identifier space. Which means to reference it we have to type 'struct bicycle' every where we want to reference it, so 'struct bicycle myBike' and if we had methods it would be 'struct bicycle a_bicycle' and that gets messy.
We want to be able to conveniently reference this without having to type out "struct bicycle" everywhere. So we've created a type definition mapping struct 'bicycle' to 'bike', so wherever the compiler sees "bike" it will know I mean "struct bicycle".
This typedef can be broken out as well to a separate line that leaves things looking like so:
struct bicycle {
char* brand;
int wheels;
};
typedef struct bicycle bike;
So now, we have a struct. Lets see if we can create an instance:
bike myBike; //Creating a new, empty instance of the type 'bike'
//It has space for my two variables but nothing in them. Lets see if we can change that
// Now lets set those variables:
myBike.brand="Mongoose"; // The only brand I remember.
myBike.wheels = 2; // I don't need training wheels if I'm wearing enough padding!
So we're saying take the bike 'myBike' and change the variable it's holding called "brand" to point to a string "Mongoose" and change the integer that it's holding called "wheels" to be '2'. Awesome. Now myBike is all set up. But... now I'd kinda like to see what I've got going... so lets print it out:
printf("My Bike is a %s brand bike with %d wheels.", myBike.brand, myBike.wheels);
Okay. So we've told printf there's a string coming, and an integer coming and given it the two parameters from our bicycle, so we run it and viola, we have output! Which we could have done those two prints separately, but I leave that as an exercise for the reader.
My bike is a Mongoose brand bike with 2 wheels.
#include <stdio.h>
typedef struct bicycle {
char* brand;
int wheels;
} bike;
int main() {
bike myBike;
myBike.brand = "Mongoose";
myBike.wheels = 2;
printf("My Bike is a %s brand bike with %d wheels.", myBike.brand, myBike.wheels);
return 0;
}