I am stumped. MAJORLY. Here is the assignment for this particular function, I have already finished 9 other functions(one with help from here :D), but this one is hard haha.
Using the get() and put() iostream functions, read in a .txt version of Pride and
Prejudice from http://www.gutenberg.org, apply the count word function to see how many words are in the fina, apply your sum ascii function, apply your single spaces, and write out the new string to a new file.
Word count and sum ascii functions are working properly, but they require a STRING, not a file. So this is the <b>unworking</b> function I have. I just want to know if I'm on the right track, or if I should take a completely different route(and what the other route is, if I do need a different one). Should I be using ios::binary to handle this large of a file?
int writePrideandPredjudice()
{
fstream streamObject;
ifstream localFile;
int count = 0;
streamObject.open("http://www.gutenberg.org/cache/epub/1342/pg1342.txt", ios::out);
localFile.open("prideandprejudice_file.txt", ios::in);
streamObject << localFile.rdbuf();
string stringOfText[localFile.length()];
for(int i = 0, i < localFile.length(); i++)
{
stringOfText[i] = localFile.get(i);
count++;
}
string spongebob(stringOfText[count]);//(don't ask... couldn't think of any more names haha)
countWords(spongebob);
sumAscii(spongebob);
doubleToSingleSpace(spongebob);
return 0;
}
I need to write the doubleToSingleSpace to a new .txt(or the existing one), but I don't know how... The rest of my function, well if you know more than me at C++, you can see it's all garbage. I really don't understand this well... and I've done quite a bit of reading on it. Any help is greatly appreciated.
bump... I also haven't used the get or put functions... and wouldn't even know how to(even though I've read up on them.... this file is really big. do I get the internet source and put into the text file?... grrr that just sounds stupid haha) I really need help on this and haven't found anything similar from an internet source to a txt file...
So, this would work, but it wont open either the internet source, nor the .txt file ( I even tried to do an absolute file name)... kind of lost here... I have no idea how to get the internet or the .txt file to actually open(It just keeps saying they failed to load)