Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm a beginner and I would like to know how to create a program that use (and save) a database. Can you please give me a simple example in C language for store name, address and phone numbers ?
Thank you very much for your attention and help.
Miroslav.

If you want to open an existing database on your own then you're talking about reinventing the database engine, which is a fairly large job. First, you'll have to find out how the target database is structured, ie. the table's definition (data type, size in bytes), then you'll need to find out how the database's file is structured, ie. where is the header, what're in the header, where the data start etc ... When you write the data back to the database file, what field in the header do you need to update etc..
Other than that, records in database are just a lumps of bytes and you can use struct to read and write from/to a file. The difficult bit is the organization of the database to allow quick access to any record at any location on the data file using keys.
The bestway is to get the database's API and use the ready written code to access the files.

Search on the net for the website of the company or person who wrote the database, see if any exists. Often companies who wrote the database engines for people to use also made the API available for developers. You'll probably need to purchase it from them.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |