I think I'm having a brain f*** at the moment. Why does this work:
...yet this doesn't:Code:#include <fstream> #include <string> int main() { char temp; std::string str( "this is a string" ); std::ofstream out( "test.txt", ios::trunc ); temp = (char)str.size(); out.write( &temp, 1 ); out.close(); return 0; };
The error I get is:Code:#include <fstream> #include <string> int main() { std::string str( "this is a string" ); std::ofstream out( "test.txt", ios::trunc ); out.write( &((char)str.size()), 1 ); // ERROR HERE!! out.close(); return 0; };
But shouldn't they be the same thing?error C2102: '&' requires l-value



LinkBack URL
About LinkBacks



CornedBee