Reputation: 1157
Is there any way where i can access? There are text files like john.txt micheal.txt james.txt ....
I can access them with this code :
ifstream file1( "james.txt", ios::in );
Can I open a file like?
string name = "james"; ifstream file1( name, ios::in )
Upvotes: 0
Views: 87
Reputation: 506
Try this:
char name[]="james.txt";
ifstream file1( name, ios::in );
Upvotes: -1
Reputation: 3744
maybe you can try something like:
ifstream file1((name + ".txt").c_str(), ios::in);
Upvotes: 4