I need help understand that code
Auto generated ID
Code:
int nextid ( ) {
static int last = 0;
return ++last;
}
Code:
struct ANIMAL {
char especie[MAX]; // ID from specie
int id; // ID Animal
char nome[MAX]; // Name of the animal
int peso; // Weight
char nomelocal[MAX]; // Place where the animal live
pno prox; // Pointer for the next
};
What i want to do is the following, i am loading animals from a text file each one i want to have a diferent ID.
(Run two diferent files one after the other and got OK)
Or in the middle of the program i want to make a baby animal and give him a automatic ID. ( Dindīt try it yet, still need to build function)
I think that code will ok, but first i don't fully understand with.
But after that part of ID i want it to remember the species.
Monkey: 1
Monkey: 2
Lion: 1
Zebra: 1
Monkey: 3
Snake: 1
How can i approach my problem ?