+ 3
Why do i get an error? And how do i fix it without actually writing "file.txt" in the argument?
string s = "file.txt"; ifstream myfile(s);
4 Answers
+ 3
@~swim~
that was not the problem.
The problem was that the function open takes in a const char* filename.
To fix that i need char s[] = "file.txt";
0
You getting an error because ifstream constructor expecting const char*, use c_str() to convert it to c string.
myfile(s.c_str());