This what I'm trying to do:
Type two or more lines of text into a file. Write a program to
open the file, reading each word into a vector<string> object. Iterate
over the vector, displaying it to cout. That done, sort the words using
the sort() generic algorithm
But I'm stuck unfortunately.
#include <iostream>
#include<fstream>
#include<vector>
#include<cstdio>
using namespace std;
int main()
{
ifstream infile("about.txt");
if(!infile){
cout<<"Sorry, file could not be open"<<endl;
}else{
vector<string> strVec;
// string eachWord[];
while(!infile.eof()){
strVec.push_back(getline(about));
}
}
return 0;
}
Error: 'about' was not declared in this scope