I wanna have my program be able to let the user manually open a text file by destination and retrieve data from it, I have everything like ifstream good, i just need to know how to let the user cin something like C:/files/myfile.txt, but with the ifstream format I need to use the format ifstream stringname("texthere"); but cant let the user modify the "texthere", im sure its just a simply command, plz help

Recommended Answers

All 3 Replies

string dir_name;
	getline(cin, dir_name);
	ifstream file(dir_name.c_str());

still doesnt work, any specific header for this, just dont work on dev c++

#include <string>
#include <fstream>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.