For a complete reference of the standard library, a good place is probably:
http://www.cplusplus.com
If you don't mind buying a book on it, one I really like is "The C++ Standard Library" by Nicolai Josuttis.
Anyway, file I/O is really easy in C++: all you have to do to open a file is:
ifstream f(filename);
Then you read from it using the regular >> operator or the "std::getline" function.
Strings are handled with the "string" class.
The part I was talking about - using a vector, then sorting it and removing duplicates, is done something like this:
#include <algorithm>
#include <string>
#include <vector>
vector<string> names;
//remove duplicates
stable_sort(names.begin(), names.end());
names.erase(
unique(names.begin(), names.end()),
names.end()
);
Don't forget to put "using namespace std" at the start of your program: otherwise you'll get weird error messages!
It's an interesting co-incidence that I've done something similar to what you're trying to do. I wrote a program to manage my meal planning, and part of it is to generate a grocery list. It extracts all the ingredients from a set of recipes and makes a big list of them, but has to remove duplicates. In case it's useful to you as an example, here is the whole function. Feel free to use the code as you wish - as long as you don't call it your own
.
/*Produce a grocery list from the ingredients of all the recipes selected
and from a file of ingredients that are always added*/
void groceryList(string infile, //recipes.txt, the list of recipes selected
string outfile, //The file that will contain the grocery list
string rcp_path) //Passed along from the caller
{
vector<string> allRecipes;
std::ifstream frecipes(infile.c_str());
string recipeName;
while (std::getline(frecipes, recipeName))
allRecipes.push_back(recipeName);
vector<string> ingredients;
//fill up ingredients with the ingredients of all recipes chosen randomly
for (int i = 0; i < allRecipes.size(); i++) {
Recipe recipe(allRecipes[i]);
string filename = rcp_path + "\\" + allRecipes[i] + ".rcp";
ifstream recipeFile(filename.c_str());
recipeFile >> recipe;
for (int j = 0; j < recipe.ingreds.size(); j++)
ingredients.push_back(recipe.ingreds.at(j).name);
}
/*Add the regular ingredients - ingredients I eat for a snack, for example,
that I always want on my grocery list*/
string filename = rcp_path + "\\extras\\reg_ingredients.txt";
string input;
ifstream regIngreds(filename.c_str());
while (!regIngreds.fail() && !regIngreds.eof()) {
getline(regIngreds, input);
ingredients.push_back(input);
}
//remove duplicates
stable_sort(ingredients.begin(), ingredients.end());
ingredients.erase(
unique(ingredients.begin(), ingredients.end()),
ingredients.end()
);
//output to a file
ofstream ingredients_txt(outfile.c_str());
ingredients_txt << "Adam's grocery list" << endl << endl;
for (i = 0; i < ingredients.size(); i++)
ingredients_txt << ingredients[i] << endl;
}