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

a 夏天 提交于 2019-12-10 15:35:46

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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++.




回答6:


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.



来源:https://stackoverflow.com/questions/4322794/how-to-save-data-in-c-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!