Im viewing some old code that has no comments which I try to understand, the code:
std::vector<std::string> CardFactory::readFile(std::string fileName)
{
std::vector<std::string> returnVal;
std::ifstream myFile;
myFile.open(fileName);
if (myFile.is_open())
{
std::vector<string> textLines;
char c[256];
//not sure why the line below this is not in the while loop
myFile.getline(c, 256);
while (myFile.good()) {
string line = string(c);
textLines.push_back(line);
myFile.getline(c, 256);
}
myFile.close();
return textLines;
}
else
{
std::cout << "File not open " << std::endl;
return std::vector<string>();
}
return returnVal;
}
It returns a vector with lines of text. I understand all the code except the part where char c is used and the value 256.
char c[256];
and
myFile.getline(c, 256);
What is the purpose of the value 256?