Basics on Creating a Struct

First, what is a struct? A struct is a "structured record" that aggregates a fixed set of labelled objects, possibly of different types, into a single object. (http://en.wikipedia.org/wiki/Struct_%28 ... anguage%29)
Let's begin with actually making a struct.
The ; is important after the }. Now we have created a struct. What you can do NOW is create a second struct and give it the properties of our first struct like so:
Now what you can do from there is define seperate information, like this:
See how this works? Hope it helps
!
Let's begin with actually making a struct.
- Code: Select all
struct PlayerInfo {
int age;
char *name;
};
The ; is important after the }. Now we have created a struct. What you can do NOW is create a second struct and give it the properties of our first struct like so:
- Code: Select all
struct Player1 PlayerInfo;
struct Player2 PlayerInfo;
Now what you can do from there is define seperate information, like this:
- Code: Select all
Player1.name="Bob";
Player1.age=22;
Player2.name="Dave";
Player2.age=25;
See how this works? Hope it helps
