开发者

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

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_JAVA百科 Closed 10 years ago.

In the internet there are databases(mysql, oracle etc.) where I can send the informations submitted by the HTML input fields with PHP or any other server side language.

How is this working in C/C++? How can I let a user input something and them save the inputted value?


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.


Why are you thinking C/C++ is different than other languages (like PHP) concerning the storage of data? You can save your data:

  • in a database (need an Open Database Connection)
  • in a tiny database such as SQLite
  • in a file

You can choose the way you want.


To let the user input something beyond the command-line you need a GUI toolkit. To communicate with databases you need a framework like MySQL Connector/C++.


look also at the following: libodbc++ - a C++ wrapper for ODBC, much more convenient than a plain C ODBC.

if you work on Linux, you may find useful info here: UnixODBC - The popular ODBC infrastructure for Linux.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜