C++ examples for File Stream:File Operation
Break a file into whitespace-separated words
#include <string> #include <iostream> #include <fstream> #include <vector> using namespace std; int main() {//from w ww. j a v a 2 s . co m vector<string> words; ifstream in("main.cpp"); string word; while(in >> word) words.push_back(word); for(int i = 0; i < words.size(); i++) cout << words[i] << endl; }