Originally posted by quzah
A structure is a group of variables bundled by a common name. Consider:
Code:
struct vehicle {
    char *name;
    int wheels;
    float milesPerGallon;
};
There. You have a vehicle. You can name your vehicle. You can give it different numbers of wheels, and you can give it a miles per gallon.

Let's say we want to make a whole list of cars at once. We will create an array of vehicles.
Code:
struct vehicles cars[] =
{
    { "Sports Car", 4, 25.5 },
    { "Family Car", 4, 30.1 },
    { "Semi Trailer", 18, 11.7 },
    { "Motorcycle", 2, 40.3 },
    { "Econo-Car", 4, 55.9 }
};
There you go. You have a bunch of vehicles. They're all defined.

You can simplify this process by defining the structure and creating the array all in one shot:

Code:
struct vehicle {
    char *name;
    int wheels;
    float milesPerGallon;
} vehicles[] =
{
    { "Sports Car", 4, 25.5 },
    { "Family Car", 4, 30.1 },
    { "Semi Trailer", 18, 11.7 },
    { "Motorcycle", 2, 40.3 },
    { "Econo-Car", 4, 55.9 }
};
See?

[edit]
Ah. Took too long replying.
[/edit]

Quzah.


oh Thank you guys.........you've all been a big help, how would I access an instance of a car with this?