Looks like its working now. Please note the changes I've made. If your serious about programming send me an email explaining what I've change. You basically had it.
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <cstdlib>
using namespace std;
void skip(ifstream& infile, ofstream& outfile, char& c);
int main ()
{
ifstream infile;
ofstream outfile;
infile.open("c:\\start.txt");
if (infile.fail())
{
cout << " Input file opening failed.\n";
exit (1);
}
outfile.open("c:\\end.txt");
if (outfile.fail())
{
cout << " Output file opening failed.\n";
exit (1);
}
char c;
infile.get(c);
while (! infile.eof())
{
if (c != ' ')
{
outfile.put(c);
}
else
{
outfile.put(c);
infile.get(c);
skip(infile, outfile, c);
}
infile.get(c);
}
infile.close();
outfile.close();
return 0;
}
void skip(ifstream& infile, ofstream& outfile, char& c)
{
while (c == ' ' && ! infile.eof( ) )
{
infile.get(c);
}
if( !infile.eof( ) )
{
outfile.put(c);
}
}