Well, one easy way to resolve this would be to save additional information in another file. Let's say we define two struct: one being the type you want the ID to be, and the other being a a "IDGenerator" type.
Code:
typedef unsigned int TypeID;
typedef struct
{
TypeID nextID;
} IDGenerator;
You could think implementing functionality for...
- Returning a unique ID
- Reseting the ID generator to 0
- Loading ID information from a FILE
- Saving ID information to a FILE
Here's what the function prototype could looks like (note that there is different way to do so):
Code:
/* Return a unique ID */
IDGenerator giveUniqueID(IDGenerator i, TypeID *newID);
/* Reset IDGenerator */
IDGenerator resetIDGenerator();
/* Load IDGenerator information from a file */
IDGenerator loadIDGenerator(FILE *file);
/* Save IDGenerator information to a file */
void saveIDGenerator(IDGenerator i, FILE *file);
This is just an idea on how it could be done. This would be rather straighforward to implement. And won't be complicated to use. If you have additional question, ask.