Change
ifstream file(filename);
to
ifstream file(filename.c_str());
Because the constructor for an ifstream
takes a const char*
, not a string
pre-C++11.
More Related Contents:
- How to extract a multiline text segment between two delimiters under a certain heading from a text file using C++ [closed]
- Fast textfile reading in c++
- Getting std :: ifstream to handle LF, CR, and CRLF?
- tellg() function give wrong size of file?
- How does ifstream’s eof() work?
- Do I need to manually close an ifstream?
- reading a line from ifstream into a string variable
- C++ ifstream failbit and badbit
- How to write to middle of a file in C++?
- How can I use non-default delimiters when reading a text file with std::fstream?
- Replace a line in text file
- How to read huge file in c++
- ifstream not reading EOF character
- How to count lines of a file in C++?
- Reading a Matrix txt file and storing as an array
- How are copy constructors used and why are they important? [closed]
- Dots in printf in C++
- How can I use std::maps with user-defined types as key?
- Difference in make_shared and normal shared_ptr in C++
- Combining C++ and C – how does #ifdef __cplusplus work?
- Forward declaring an enum in C++
- What does auto&& tell us?
- How to find if a given key exists in a C++ std::map
- C++ auto keyword. Why is it magic?
- How to store variadic template arguments?
- Using multiple .cpp files in c++ program?
- The behaviour of floating point division by zero
- C++ covariant templates
- Regex C++: extract substring
- how to get hash code of a string in c++