a friend of mine asked me to write a little ditty for her to read sentences from a text file, and print them out in a random order making a big random paragraph. The only thing so far I seem to have problem with is the actual loading of the strings from the file into my array.
infile>>sentences[] seems to be produces lackluster results. I think i might have to ignore whitespace? not sure how i would do that, im a bit rusty.
string sentences[100];
ifstream inFile;
ofstream outFile;
inFile.open("./sentences.txt");
outFile.open("./random.txt");
for(int i=0; i < 99; i++)
{
if(inFile != EOF)
inFile.getline(sentences[i],1000, '\n');
else
break;
}
also that EOF might be borked, havent checked yet
infile>>sentences[] seems to be produces lackluster results. I think i might have to ignore whitespace? not sure how i would do that, im a bit rusty.
string sentences[100];
ifstream inFile;
ofstream outFile;
inFile.open("./sentences.txt");
outFile.open("./random.txt");
for(int i=0; i < 99; i++)
{
if(inFile != EOF)
inFile.getline(sentences[i],1000, '\n');
else
break;
}
also that EOF might be borked, havent checked yet
