- #1
Jamin2112
- 986
- 12
I can't figure out why my text file isn't being found. I have it saved in the same location as my project. Anyone know how I can set where XCode checks for an fstream object?
Code:
int main (int argc, char* const argv[]) {
std::fstream file1("CollegeIsAWaste.txt", std::ios_base::in);
std::vector<std::vector<std::string> > fileSentences = get_file_sntncs(file1);
return 0;
}
std::vector<std::vector<std::string> > get_file_sntncs(std::fstream& file) {
// The sentences will be stored in a vector of vectors of strings:
std::vector<std::vector<std::string> > retvec;
if(file.fail()) {
std::cout << "Could not find the file. :( " << std::endl;
} else {
char thischar;
std::string thisword.
std::vector<std::string> thissentence;
// --- TEST: Print to make sure it's reading correctly ----
while (file >> std::noskipws >> thischar) {
std::cout << thischar;
// --------------------------------------------------------
}
// P
// ...
}
return retvec;
}