title: Write file in binary format
body: <p>I am trying to write the file in binary format. I have the following code with me, but it save the file in text format.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main(){
      std::string ref = "Ecoli. 123";
      unsigned int size = 124;
  
      std::ofstream supp_info_output("binary_file",  std::ios::out | std::ios::binary); // saving file
      supp_info_output &lt;&lt; ref &lt;&lt; std::endl;
      supp_info_output &lt;&lt; size &lt;&lt; std::endl;
      supp_info_output.close();
  
      std::ifstream supp_info_input("binary_file", std::ios::in | std::ios::binary); // loading file
      std::string supp_info_line;
      while( std::getline( supp_info_input, supp_info_line ).good() ){
          std::cout &lt;&lt; supp_info_line &lt;&lt; std::endl;
      }
      supp_info_input.close();
  }
  </code></pre>
  
  <p>In the code I am writing some data and then reading the data again. There is no problem in reading and writing,but I need the file in binary format.</p>