I would like my program to read a file using the function \"readFile\" below. I am trying to find out how to call a function with an istream& parameter. The goal of the
The first argument to the std::ifstream
constructor should be a string. You're trying to pass it a std::istream
. Maybe the std::istream
contains the name of the file you want to read, in which case you want to extract the name into a std::string
first. Something like this might work:
std::string fileName;
name >> fileName;
std::ifstream file(fileName, ios::in);