The following does not work and gives me a SIGABRT when I run in the debugger:
std::ifstream inFile;
inFile.open("/Users/fernandonewyork/inputText.txt");
cout << inFile << endl;
vector<string> inText;
if (inFile) {
string s4;
while (inFile>>s4) {
inText.push_back(s4);
}
}
inFile.close();
The following does:
std::ifstream inFile;
inFile.open("/Users/fernandonewyork/inputText.txt");
cout << inFile << endl;
vector<string> inText;
if (inFile) {
string s4("This is no lnger an empty string");
while (inFile>>s4) {
inText.push_back(s4);
}
}
inFile.close();
I was under the impression I was able to simply use s4 without having to worry about any space considerations, or is something else happening here? This is the full error I get from the top code:
malloc: * error for object 0x100010a20: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug Program received signal: “SIGABRT”.