Format Text - ofstream-ifstream

I'm having problem with a program im trying to write that reads a .text sourcefile and then format the .text file while removing excess whitespace.

#include <fstream>
using std::ofstream;
using std::ifstream;
#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
#include <sstream>
#include <iomanip>
#include <cstring>
using std::string;
using namespace std;
#include <cstdlib>
using std::exit;
#include <stdio.h>


int main (void)
{

const int MAX = 100;
char buff[MAX];
string name;
int i;
int countWords(const char string[]);
void readLine(char buffer[]);

cout << "Enter name of input text file(location on disk): "<<endl;
getline (cin, name); //Prompts user to input source text

ifstream input; //create stream object homework
input.open ( name.c_str() ); //reads source text file

if (!input) {
cerr << "Unable to open file hw6.txt";
exit(1); } // call system to stop
else{
while (!input.eof()) //until end of file
{
input.getline(buff, MAX); //read line of text

cout << buff << endl;
} //display text(pre-formatted)
}

cout << "Enter name of the output text file: " <<endl;
getline (cin, name); //Promt user to input output text

ofstream output; //create stream object homework2
output.open (name.c_str() );

if(!output){
cerr << "Unable to create text file\n";
exit(1);} //call system to stop
}

I'm having issues formatting the input stream text file(removing excess whitespace.


Demo text:

The
kid is
playing in the field
because he doesn't want to go inside.

Output text(supposed to look like).
It should look like this:
The kid is playing in the field because he doesn't want to go inside.


Iterate through input strings and delete newlines. Then concatenate the fixed string to the output string and write it back to the file.
I did that already, What i'm trying to do is remove the excess white space from the source text file and save it to another file with ofstream. Every word should be separated by one space " " and each line should be 100 characters long.
Topic archived. No new replies allowed.