Saving?!

Hello,

I know this may sound like a stupid question but i cant figure out how to make a database(?) What i am tring to do is make a program to keep track of my clients.... So i figrued that i would just wright all the clients into a txt file.... that works.. but i cant figure out how to edit the entries from the text file... the i thought i was doing it wrong.... so far all i have figured out is that using a .txt file to save work from a program is not how you go about it. if any one could tell me what i am suposed to do or a place to find it please tell me.

Yes, but what i was going for was like an address book, and it lets you add more people. However it should let you slect one to view it in more detail(money they owe, venue, performnces, ect..). Hence the reason why .txt files wont work... or maybe they will, but what i am tring to say is that if use .txt files i'm going to end up with about 30 of them... I'm just looking for a better way to solve the problem...

>i cant figure out how to make a database(?)
For a simple database you can use a single file (or several files that you choose from based on a search key) to hold the records, then read them into a suitable data structure in memory. Any changes made to the database would be done in memory, then written back to the file to save them. For a larger and more professional database, you're looking at writing an external data structure such as some variant of a B-tree to give you efficient lookup and modification without having to read every record into memory. However, I wouldn't recommend that particular path unless it is absolutely necessary, external B-trees are not trivial to write.

>i dont think you get what i am asking...
I'm well aware of what you want to do. However, I'm also pretty sure you don't want to do what you think you do.

>so what i want to be able to do is pick a spot in a file and only read that block....
This is simple provided you use binary files and have a strict indexing scheme as well as records that will never vary in size. For most applications, this is too restrictive, so we usually recommend processing whole files instead of individual records.

>>so what i want to be able to do is pick a spot in a file and only read that block.... not sure if it is possible tough because i tired everything.

if all you want to do is read, I suggest using an XML file... it looks prettier, but it's a little more code to parse the XML file than just search for a name in a list... you could set it (txt file) up this way:

and then search for the name and only load the next four lines... that works good for one search per run of the program and no inserting... if you're planning on having it search the file multiple times, it's easier to put the file in a linked list or even an array of structs... either way, if you want to insert something in a specific place, it's much easier to go with an array of structs or linked list...