How to save data in C/C++? [closed] How to save data in C/C++? [closed] database database

How to save data in C/C++? [closed]


You can either:

  1. Make use of the standard file handling functions/classes.
  2. Embed a tiny database.
  3. Talk to a database server using a standard interface.

BTW, these are common for all languages.


Really depends what you want to save.

There are libraries (like this one) that will let you connect to SQL databases from C++.

Another approach would be to save/load it to a file. For simple things just filestreams may be good enough, other times you may want something a bit more hard-wearing like boost::serialization to take some of the hard work out of it.


Are your talking about desktop(standalone) application or some web-app? And it depends on what type of information are you going to store. Perhaps, windows registry would be enough.

Also you can use MySQL for storing data. There are a lot of tutorials on how to work with MySQL via C++. Here's a convinient api.

And your should read this.