When I'm trying to read a file with a function
void readFile(string fileName, string* anArray) {
unsigned int lineCounter = 0;
ifstream inFile = ifstream(fileName);
while (!inFile.eof()) {
string fileLine;
inFile >> fileLine;
if (!fileLine.empty()) {
anArray[lineCounter] = fileLine;
++lineCounter;
}
}
inFile.close();
}
I get the error below, which I assume is because of the pointer on the string array ?
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl resource::readFile(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator > *)" (?readFile@resource@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAV23@@Z) referenced in function _main
resource::readFile. Which source file is it defined in, and are you linking to it? - Vaughn CatoreadFilesupposed to be a member function defined outside of the classresource? If so you likely meantvoid resource::readFile(...) {. - Joe