C++ I/O

File Output
using namespace std; ... ofstream file("test.txt"); file << "whatever"; file.close;
 * 1) include

Linewise
using namespace std; ... ifstream file("test.txt"); if(!file) throw Exception("Couldn't open file!"); string line; while(!file.eof) { getline(file, line); cout << "'" << line << "'" << endl; } file.close;
 * 1) include

Directory Scanning
Output full pathname of all files in 'path' and subdirs: // link with -lboost_filesystem using namespace boost::filesystem; using namespace std; class NoSuchPathException {}; void findFiles(const string& path) throw(NoSuchPathException) { if(!exists(path)) throw(NoSuchPathException); // for all dirs directory_iterator end_itr; // default construction yields past-the-end for(directory_iterator i(path); i != end_itr; ++i) { // if dir, recurse if(is_directory(*i)) findFiles(i->string); // output file name else cout << i->string; } }
 * 1) include 
 * 2) include