No Match for fstream::write().
I am using Mingw gcc compiler and when I compiled this code I got an error:
Code:
mand.cpp:38: no matching function for call to `std::basic_fstream<char,
std::char_traits<char> >::write(unsigned char[100], const int&)'
E:/MinGW/include/c++/3.2.3/bits/ostream.tcc:387: candidates are:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::write(const _CharT*, int) [with _CharT = char, _Traits =
std::char_traits<char>] <near match>
The line was :
Code:
fstream file("IMAGE.RAW", ios::out|ios::binary);
if(!file){
cout<<"\nError Opening file...\n\n";
return 1;
}
for(int i=0; i<SIZE; ++i)
file.write(Canvas[ i], SIZE); //this line
file.close();
cout<<"\nFILE WRITTEN\n";
return 0;
}
/*
where
unsigned char Canvas[SIZE][SIZE]={'\0'};
const int SIZE = 100; //global;
*/
I am not sure about the cause of the error;
This function worked in my prestandard compiler in some other program.
So what function should I use to achieve a similar purpose?
And what's with all the'<>' symbols in the error report? I did'nt know that fstream was 'templated'