how to use a file path

hello

how to let user to input the path of a file in c++

then the program will take the path

and read data from file....
1
2
3
std::string path;
std::cin >> path;
std::ifstream infile(path);

Something like this?
yes
i found c_str() function
how i can use it ?
Ah yes, fstreams use c-strings to open files. Sorry, I forgot.
std::ifstream infile(path.c_str());
thanks
it's work :)
Topic archived. No new replies allowed.