I am writing a program that will access several hundred words frequently, so instead of storing them all in a .txt file and having to use cpu and hard drive to access, process and store in a vector I want to include them inside the program. What is the best way to go about doing that? (while keeping source code clean)
The program will identify nouns using pronouns, verbs, etc… in a question.
(I am using MV)
*edit
I guess the best option is to load data into the program upon initialization, based on responses below.
The best way is to store them program in a array like so if they are already known at compile time.
And within the program you can access them likes
words[0]andwords[1]etc etc. Depending on your operating system programs are also allowed to have embedded resources. You can use that approach as well.You can also store them as you are doing currently as well. Hunderds of words should be read in pretty quickly. Extraneous file has an advantage that they can be changed without recompiling the file. But might suffer from the disadvantage that when you distribute your program you have to distribute your extra file as well. Users may muck around with a plain text file and you will have to handle malformed input file too.
You haven’t mentioned how you are planning to access these words. Depending on that you might need other data structures like
set,mapor maybe even aTrie