The boost tokenizer class is an excellent library made readily available that can accomplish this:
http://www.boost.org/libs/tokenizer/tokenizer.htm
Also, this code may be useful:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//...
string file,line,word...