read txt file with the name is variable???

i want to load txt file, but the name of txt file is variale. please hepl me!!!
my code is error!!!

String ^ s;
s="t";
ifstream txt (s+".txt");///error

im a beginers!!
thanks
Last edited on
1
2
3
4
5
6
7
8
9
#include <string>
#include <fstream>

int main()
{
    std::string s = "t";
    std::ifstream txt(s + ".txt"); // modern compiler
//    std::ifstream txt( (s + ".txt").c_str() ); // old compiler
}
Last edited on
thanks
Topic archived. No new replies allowed.