Saving and searching Data

I have a bit of a project to do but I dont have a bit of a clue in saving and searching for data. I was told to do a program that saves the date and time of a person registering, and records it. and then if I want to check it, it shows a little calindar that shows that person's attendance.

make I ask on how this is done.
please and thank you
I am a busy man but I want to help.

http://msdn.microsoft.com/ is your friend.

Personally for a small project and to make life simple I would create your structures using STRUCT.
e.g.
struct PERSON{
char christianName[61]; // initialise using strcpy(person.christianName, "")
char surname[31];
short unsigned number; // initialise using number = 0;
};

For a start just store your date-day,month,year,hour and minute straight in the structure. Have a look at http://www.cplusplus.com/reference/clibrary/ctime/localtime/ for date/time features.

For writing and reading your data have a look at either CreateFile on MSDN or fstream for C++ specific.

You can read and write data using the structure you declared. Keep repeating until the end of file or until you get to the item you want
e.g. ReadFile(hFile,
&person, // pointer to a variable of type PERSON - yes right in to the structure
sizeof(PERSON), // the size of the structure
&lBytesWritten, // Size that was read
0);

Don't worry about building indexing or search structures unless you are dealing with over 10,000 records. Otherwise your database will get slower not faster. Simply go through your data record by record until you get what you want.

Unsure on the exact c++ platform you use, DateTimePicker is how you show both date and times. Call CreateWindow with DATETIMEPICK_CLASS as the class, or paint it on. If you are not using a c++ with paint then you must call InitCommonControlsEx with ICC_DATE_CLASSES for date/times to work.


Finally if your told to build indexing or searching in to it with your tutor/teacher then get the simple stuff out of the way first then it depends how much of a merit you want how you approach it.
1. A common way is to create a new struct layout for indexing your data, e.g. It is sorted, a list of your record numbers and where in the file it sits. Then if you need to search by name then name and record number. And so on.
2. A super efficient way is to use linked lists (nested pointers) to store the index file in memory, and load linked lists with commonly retrieved data in to memory as well (cache and prefetch cache).


Most importantly, do not touch any code until you have done some sort of diagramming on paper (possibly UML). Most databases are filled with redundant fields or indexed incorrectly because this first step is not done.
thanks, I'll have to see what I can do with this, I havent started but I'll try it
Topic archived. No new replies allowed.