Saturday, December 17, 2011

Why is this c++ program not working (it is mainly a problem with the iostream library)?

//the idea, is for it to be cross platform, and open files in binary mode


#include %26lt;iostream%26gt;


#include %26lt;stdlib.h%26gt;


using namespace std;


int main()


{


string input;


cout %26lt;%26lt;"please input the full file name:"%26lt;%26lt;endl;


cin %26gt;%26gt;input;


cout %26lt;%26lt;endl%26lt;%26lt;endl;


ifstream file(input, binary);


file %26gt;%26gt;input;


cout %26lt;%26lt;input;


return 0;


}/*keep getting this error: "binary_file_reader.cpp:10: error: variable 鈥榮td::ifstream file鈥?has initializer but incomplete type"*/|||You need to #include %26lt;fstream%26gt;





also, the call to fstream's constructor should be


ifstream file(input.c_str(), ios::binary);

No comments:

Post a Comment