ok I am required to write a program that reads text from one file and writes it to another. I can do that easily enough but the second file the text is wrote to is supposed to have no spaces in between the words. how do I do this?
here is the code if that would help any.

#include <iostream.h>
#include <fstream.h>


int main ()
{
  char in;
  ifstream infile ( "in.dat" );
  ofstream outfile ( "out.dat" );

  if ((!infile) || (!outfile))
  {
    cout << "error opening file\n";
    return 0;
  }

  while ( infile.get ( in ) )
  {
	  cout<< in;
	  outfile << in;
  }
      infile.close;
	  outfile.close;

  return 0;
}

Add a simple test before you print to the file:

if ( in == ' ' )
  continue;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.