C++ ifstream as parameter
#include <iostream> #include <string> #include <fstream> using namespace std; string ReadString(ifstream &file)//from w ww .j av a2 s. co m { char buf[1024]; // Make sure this is big enough! file.getline(&(buf[0]), 1024, ';'); return string(buf); } int main() { ifstream delimfile("../delims.txt"); while (1) { string words = ReadString(delimfile); if (delimfile.eof() == true) break; cout << words << endl; } delimfile.close(); return 0; }