The first error you need to overcome is this one:
main.cpp:3:20: fatal error: ifstream: No such file or directory
#include <ifstream>
^
compilation terminated.
Indeed, this header does not exist. You probably meant fstream
.
Once that is corrected, the crux of your issue is:
main.cpp: In function 'int main()':
main.cpp:11:29: error: no matching function for call to 'std::basic_ifstream<char>::basic_ifstream(std::string&)'
ifstream myfile(filename);
This is because fstream
constructors, in C++98 and C++03, did not take string arguments. This was a sort of legacy oversight, fixed in C++11.
You have two choices:
In both of the above examples, I've had to remove your entire while
loop because it references symbols not declared in your program. When reporting a problem, please take more care, and present a testcase that contains only the problem you're trying to solve.