ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
my sourcecode is on http://pastebin.com/356038 . My problem is that i can now create the file, but how do i change the code so that it asks user for the path to filename and then stores that info into games.db please? Thankyou
Please use useful thread titles in future. This one mught be polite, but it's not useful at all...
not quite sure what you're really asking anyway... You are already successfully using the cin stream to read a variable so surely you can just use what you already know?
ok iv managed to get my code to ask the user for the path to the file, the problem iv now got is when you enter the path, it quits out of my program and dont store it into games.db like what i need it todo. Please help?
i think you have to overload the out operator, something like:
Code:
#include <fstream>
using namespace std;
int main () {
ofstream outfile;
outfile.open ("test.txt", ofstream::out | ofstream::app);
outfile << "This sentence is appended to the file content\n";
outfile.close();
return 0;
}
Re: Sorry to be a pain, but can someone help please?
Quote:
Originally posted by twirl Hi,
my sourcecode is on http://pastebin.com/356038 . My problem is that i can now create the file, but how do i change the code so that it asks user for the path to filename and then stores that info into games.db please? Thankyou
Thankyou for the help :-). I have now got my program working with it saving the data to the games.db (sourcecode at :- http://pastebin.com/356387) now iv got to work out how to get user to specify location of config file and then open that file for editing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.