file filtering
-
i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. so what kind of storage format i should go for to make my retrival easy.
-
i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. so what kind of storage format i should go for to make my retrival easy.
Unless you are not willing to use any fancy database approach and run some queries, you could go for an ASCII file, in which each line could contain text like:
22-Name
where the id is followed by a "-" and the name itself. Then you use aCStdioFile
object to read the file line by line. Assuming now that you get the line info into somechar chText[256]
variable, you go then for something like this:char chName[256]; unsigned int ID; sscanf(chText, "%u-%s", &ID, chName);
As soon you get the ID value you are looking for, you stop the process of reading the file, close the file and returnchName
I'm pretty sure, some other ways exist as well :-)) SkyWalker -
i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. so what kind of storage format i should go for to make my retrival easy.
karmendra_js wrote: i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. In Continuation with Mr. Puiu, if you like to have light Database approach .... you can try embedded database like Sqlite:- here is an article related to it :- http://www.codeproject.com/database/vmembedded_db_cpp.asp[^] http://www.codeproject.com/database/CppSQLite.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV