Hey codecall, I'm creating a Quiz Generator program that takes user defined data and formats it into a quiz format. The problem is I need a way to save data, preferably strings so that they can be reaccessed later. I was wondering what library would be recomended for doing this, I was looking at using the fstream library to save text to a .txt document. This would require a bit of work for reading the input and then restoring the data in a vector, and I was wondering if there is a simpler way to store data. Thanks.
fstream library: Input/Output with files
5 replies to this topic
#1
Posted 18 November 2010 - 08:41 PM
|
|
|
#2
Posted 18 November 2010 - 11:35 PM
Couldn't you use database? Logically database is the first candidate, since I believe you have to add some properties to the stored questions for faster retrieval later. For example, you may want to categorize the questions, or you may want to weight them (like easy, medium, and difficult).
#3
Posted 19 November 2010 - 02:17 AM
Hi,
Yes, the most simplest way is to use files. You can use fstream/FILE for file io.
Yes, you can even use an embedded database; this also saves the data into files, but you can access data through SQL. For example, SQLITE is an embedded database, that you would like to use in your application. More details are
SQLite Home Page
this is free to use.
If you want to use a free relational database, you may want to look at MySQL.
MySQL :: The world's most popular open source database
I hope this helps!
Munir
Yes, the most simplest way is to use files. You can use fstream/FILE for file io.
Yes, you can even use an embedded database; this also saves the data into files, but you can access data through SQL. For example, SQLITE is an embedded database, that you would like to use in your application. More details are
SQLite Home Page
this is free to use.
If you want to use a free relational database, you may want to look at MySQL.
MySQL :: The world's most popular open source database
I hope this helps!
Munir
#4
Posted 19 November 2010 - 06:46 AM
I forgot about SQLITE, Im familiar with it in Lua. I will look into it I doubt its very complex, and that way everything can be stored in a single database versus multiple files. I do have web hosting so I could use MySQL but I dont want this program to be web based. Thanks for the input, I will go research SQLITE.
#5
Posted 19 November 2010 - 08:08 PM
espdev-darkness said:
will go research SQLITE.
The syntax would look something like this with it, it looks a lot more simple than sqlite's wrapper:
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
#include <string>
#include "Database.h"
#include "Query.h"
int main()
{
Database db( "database_file.db" );
Query q(db);
q.execute("delete from user");
q.execute("insert into user values(1,'First Person')");
q.execute("insert into user values(2,'Another Person')");
q.get_result("select num,name from user");
while (q.fetch_row())
{
long num = q.getval();
std::string name = q.getstr();
printf("User#%ld: %s\n", num, name.c_str() );
}
q.free_result();
}
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#6
Posted 19 November 2010 - 08:30 PM
Im a little confused as to what a wrapper is... From googling it I have found out very little.
*edit: For version one of this program it looks like I will just use fstream, file i/o is all I need the formating isn't to complex. I found an excellent tutorial here: fstream Tutorial - C++.
*edit: For version one of this program it looks like I will just use fstream, file i/o is all I need the formating isn't to complex. I found an excellent tutorial here: fstream Tutorial - C++.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









