std::ifstream ifs("foo.txt"); // ifstream: Opens file "foo.txt" for reading only. std::ofstream ofs("foo.txt"); // ofstream: Opens file "foo.txt" for writing only. std::fstream iofs("foo.txt"); // fstream: Opens file "foo.txt" for reading and writing.