Code tags usually make it much easier to read, but in your case, there is no formatting either so it doesn't help much. Format your code and repost it in code tags please.
[code=cplusplus]
// paste code here
[/code]
void remove_extra_spaces(ifstream& in_stream, ofstream& out_stream)
{
char next, previous;
int counter = 0;
in_stream.get(next);
cout << next;
while (! in_stream.eof())
{
in_stream.get(next);
cout << next;
out_stream << next;
if (next == ' ')
{
previous = next;
in_stream.get(next);
if (next == ' ' && previous == ' ')
{
cout << "";
out_stream << "";
counter++;
}
else
{
in_stream.get(next);
cout << next;
out_stream << next;
}
}
else
{
in_stream.get(next);
cout << next;
out_stream << next;
}
}
cout << endl << endl;
cout << "There are " << counter << " characters in this document.\n";
cout << endl << endl;
}
Lines 19 and 20 don't make much sense to me. What's the point of outputting an empty string? Those lines can be deleted. The code is impossible to follow without the proper indentation. You want something like this:
if (a == b)
{
if (c == d)
{
cout << "Hello world.";
// more code
}
else
{
cout << "Hi world."
// more code
}
}
else
{
cout << "Goodbye world.";
// more code
}
Styles vary, but I prefer each new nested if-statement block to be indented by about four spaces (spaces, not tabs. Tabs look terrible when posted on Daniweb).