I am currently working on a small project in C++ and am a bit confused at the moment. I need to read a certain amount of words in a line that is taken from a file using ifstream in(). The problem with it right now is the fact that it keeps ignoring spaces. I need to count the amount of spaces within the file to calculate the number of words. Is there anyway to have in() not ignore the white space?
ifstream in("input.txt");
ofstream out("output.txt");
while(in.is_open() && in.good() && out.is_open())
{
in >> temp;
cout << tokencount(temp) << endl;
}