Messy as my coding style is, I feel this should be compiling in g++, so why might it not be? What options should I be compiling this with when I type g++ (for proper linkage)? Many thanks and 1,000 internets to any willing to sift through my code!
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include "StringWrap.h"
#include "PhraseJMK.h"
usingnamespace std;
int main(int argc, char *argv[])
{
fstream file;
vector<string> dass;
vector<Phrase> diese;
string temp;
int truth = 0;
bool flag;
flag = 0;
char period = '.';
int words = 0;
int letters = 0;
StringWrap hilfer1;
StringWrap hilfer2;
Phrase* see;
//Retrieves file name and subsequently opens it.
//cout << "Enter your name of the file you want to open: ";
//cin >> (temp);
//char* offnen = (char*)temp.c_str();
file.open(argv[0]);
while(!file.eof())
{
file >> temp;
dass.push_back(temp);
}
//How many words in file
cout << "There are " << dass.size() << " many words in the file. \n";
for(int i=0; i < dass.size(); i++)
{
truth += dass[i].size();
}
//How many characters are in the file.
cout << "There are " << truth << " many characters in the file. \n";
//Word by word
for(int i=0; i < dass.size(); i++)
{
//Letter by letter
for(int j=0; j < dass[i].size(); j++)
{
if((dass[i].at(j) == period) || (dass[i].at(j) == '!') || (dass[i].at(j) == '?'))
{
flag = 1;
}
}
words++;
if(flag == 1)
{
temp += dass[i];
see = new Phrase(temp, words);
diese.push_back(*see);
temp = "";
words = 0;
}
if(flag == 0)
{
temp += dass[i];
temp += " ";
}
flag = 0;
}
//Get the amount of words in each sentence, as well as the amount of characters
//This is a printout of the file.
for(int i = 0; i < diese.size(); i++)
{
cout << "Phrase below has " << diese[i].getNum() << " words. \n";
cout << "Phrase below has " << diese[i].getPhrase().size() << " characters. \n";
cout << diese[i].getPhrase() << "\n\n";
}
hilfer1 = StringWrap(diese[diese.size() - 2].getPhrase());
hilfer2 = StringWrap(diese[diese.size() - 1].getPhrase());
hilfer1.makeLower();
hilfer1.trimNonAlpha();
hilfer2.makeLower();
hilfer2.trimNonAlpha();
if(hilfer1.str().at(0) <= hilfer2.str().at(0))
{
cout << "The last phrase is greater than its preceding phrase: " << hilfer2.str() << " \n > " << hilfer1.str();
}
else
{
cout << "The last phrase is less than its preceding phrase: " << hilfer2.str() << " \n < " << hilfer1.str();
}
}