the following code cannot pass the compiler:
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
fstream outfile("i:\\te st.txt", ios_base::in | ios_base::out);
long lFlag = outfile.flags() ;
outfile.setf(io s_base::app);
cout << hex << "Original flag : " << lFlag << '\n'
<< "Now flag : " << outfile.flags() << '\n';
if (outfile.flags( ) & ios_base::app)
cout << "append bit set!\n";
char ch;
while (cin >> ch)
outfile << ch;
cout << '\n';
outfile.seekg(0 );
while (outfile.get(ch ))
cout << ch;
cout << '\n';
return 0;
}
the compiler returns the errors:
test3.cpp: In function `int main()':
test3.cpp:11: no matching function for call to
`std::basic_fst ream<char,
std::char_trait s<char> >::setf(const std::_Ios_Openm ode&)'
i:/mingw/include/c++/3.2/bits/ios_base.h:342: candidates are:
std::_Ios_Fmtfl ags std::ios_base:: setf(std::_Ios_ Fmtflags)
i:/mingw/include/c++/3.2/bits/ios_base.h:350:
std::_Ios_Fmtfl ags std::ios_base:: setf(std::_Ios_ Fmtflags,
std::_Ios_Fmtfl ags)
but there is no problem with both bcc5.5 and vc6.0.
my system is Windows2000 and i use the gcc2.3.2 shipped with
mingw2.0.3.
what's the matter with gcc2.3.2 or my program?
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
fstream outfile("i:\\te st.txt", ios_base::in | ios_base::out);
long lFlag = outfile.flags() ;
outfile.setf(io s_base::app);
cout << hex << "Original flag : " << lFlag << '\n'
<< "Now flag : " << outfile.flags() << '\n';
if (outfile.flags( ) & ios_base::app)
cout << "append bit set!\n";
char ch;
while (cin >> ch)
outfile << ch;
cout << '\n';
outfile.seekg(0 );
while (outfile.get(ch ))
cout << ch;
cout << '\n';
return 0;
}
the compiler returns the errors:
test3.cpp: In function `int main()':
test3.cpp:11: no matching function for call to
`std::basic_fst ream<char,
std::char_trait s<char> >::setf(const std::_Ios_Openm ode&)'
i:/mingw/include/c++/3.2/bits/ios_base.h:342: candidates are:
std::_Ios_Fmtfl ags std::ios_base:: setf(std::_Ios_ Fmtflags)
i:/mingw/include/c++/3.2/bits/ios_base.h:350:
std::_Ios_Fmtfl ags std::ios_base:: setf(std::_Ios_ Fmtflags,
std::_Ios_Fmtfl ags)
but there is no problem with both bcc5.5 and vc6.0.
my system is Windows2000 and i use the gcc2.3.2 shipped with
mingw2.0.3.
what's the matter with gcc2.3.2 or my program?
Comment