#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "stdlib.h"
using namespace std;
void flush_left ( ofstream out_file, int num,
vector <string> vec_words)
{
for ( int i=0; i<num; i++)
{
out_file << "-" << endl;
}
for ( int i=0 ;i < vec_words.size(); i++)
{
int line_counter = 0;
if ( line_counter == 0 )
{
out_file << "| ";
}
else
{
if ( line_counter + vec_words[i].size() <= num )
{
line_counter = line_counter + vec_words[i].size();
out_file << vec_words[i] << " ";
}
else
{
for ( int i = line_counter; i< num; i++)//or num-1.
{
out_file << " ";
}
out_file << "|" << endl;
}
}
}
}
void flush_right ( ifstream file, int num )
{
}
void full_justify ( ifstream file, int num )
{
}
int main( int argc, char* argv[])
{
ifstream file(argv[1]);
if ( !file )
{
cerr << "Can't open " << argv[1] << " to read. \n";
return 1;
}
string words;
vector <string> vec_words;
while ( file >> words )
{
vec_words.push_back(words);
}
ofstream out_file( argv[2]);
if ( !out_file)
{
cerr << " Can't open " << argv[2] << " to write.\n";
return 1;
}
int number = atoi(argv[3]);
string name = argv[4];
if ( name == "flush_left" )
flush_left ( out_file, number, vec_words );
}