Dan Posted September 27, 2005 Report Share Posted September 27, 2005 Is there anywya to make a program in C++, that can save data to a disk (like an ini file), and read information.Ex.A wrestling program.Select option: (1 for edit, 2 for new, 3 for delete) 1then comes up all of his points for the year.Is this possible?dk Quote Link to post Share on other sites
jcl Posted September 27, 2005 Report Share Posted September 27, 2005 (edited) Sure. That's why the fstream classes (ifstream, ofstream, and iofstream) and most of <cstdio> exist. Even without those, you could use the platform I/O API or, on many platforms, redirect the standard I/O streams to files.But it's important to know exactly what you need the program to do. If all you need is a way to persist the information, you can overload operator<<() and operator>>() to (de)serialize the data without too much trouble. If you also need to be able to change the on-disk data (or even read it) or if it's fairly complex you would probably want a more structured format (INI, XML), but that would require at least a parser for the read side (you could munge it manually for the writes). If you're really trying to make a database, use a database. Wrap it in a C++ front-end if you like. Edited September 27, 2005 by jcl Quote Link to post Share on other sites
Dan Posted September 27, 2005 Author Report Share Posted September 27, 2005 would it be easyer in another language Quote Link to post Share on other sites
shanenin Posted September 27, 2005 Report Share Posted September 27, 2005 (edited) you can't beat python for ease of use and fast results.to write to a file, this is as simple as it getsfile = open("filesw.ini", "w")file.write("text to be written, gos here") Edited September 27, 2005 by shanenin Quote Link to post Share on other sites
Hai-Etlik Posted September 27, 2005 Report Share Posted September 27, 2005 you can't beat python for ease of use and fast results.to write to a file, this is as simple as it getsfile = open("filesw.ini", "w")file.write("text to be written, gos here")<{POST_SNAPBACK}>C++ isn't much more complex for that particular example. It just has more boilerplate.#include <fstream>#include <iostream>int main(){std::ofstream fout ("filename");fout<<"Some text"<<std::endl;}Given the description of the problem, I almost think a simple spreadsheet would be the best option. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.