Issues with cin

I need to send an ifstream variable to a function, but the file directory needs to be user-defined. I have:
ifstream inData;
cin >> inData;

The >> operator becomes highlighted with an error message: no operator ">>" matches these operands.

I receive the same message for string types but not for integers or doubles.
closed account (Dy7SLyTq)
thats not how that works. you use
ifstream::open(char* FileName) // can also specify flags after file name
c++11: open(std::string)
What if I don't have the file name though? I need to write the program so it collects the directory location from the user.
std::string filename = "";
std::cout << "Please enter a filename.\n> " << std::flush;
std::cin >> filename;
ifstream in( filename.c_str() );
closed account (Dy7SLyTq)
unless your doing c++ 11 in which case you dont need the .c_str()
Topic archived. No new replies allowed.