c++ ifstream undeclared identifier
You need to reference the standard namespace (std). Try this:
#include <iostream>
#include <iomanip>
#include <fstream>
void main()
{
std::ifstream infile("file.txt");
std::ofstream outfile("out.txt");
}
You need to scope it. Use using namespace std;
or preface ifstream
and ostream
with std::
For example, std::ifstream
Currently, the compiler does not know where these structures are defined (since they are declared/defined within the std
namespace). This is why you need to scope your structures/functions in this case.