title: no match for 'operator !='
body: <p>A question from a C++ newbie. Forgive me if its a simple one.</p>
  
  <p>I am trying to run a *.cpp code that reads a text file and outputs a formatted file. However when running the code, I am getting some compilation  errors. I have attached herewith the code and errors.</p>
  
  <p>The code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  #include&lt;fstream&gt;
  const int cell = 1;
  using namespace std;
  int main()
  {
  int id[cell],crop[cell],n;
  double root_depth1[cell], root_depth2[cell], root_depth3[cell], root_fract1[cell], root_fract2[cell], root_fract3[cell], x;
  double LAI_1[cell],LAI_2[cell],LAI_3[cell],LAI_4[cell],LAI_5[cell],LAI_6[cell];
  double LAI_7[cell], LAI_8[cell], LAI_9[cell], LAI_10[cell], LAI_11[cell], LAI_12[cell];
  
  ifstream read;
  
  read.open("veg_par_in.txt");
  if(read != 0)
  {
      for (int i=0;i&lt;cell;i++)
  {
      read&gt;&gt;id[i]&gt;&gt;crop[i]&gt;&gt;root_depth1[i]&gt;&gt;root_fract1[cell]&gt;&gt;root_depth2[cell]&gt;&gt;root_fract2[cell]&gt;&gt;root_depth3[cell]&gt;&gt;root_fract3[cell];
  
      read&gt;&gt;LAI_1[i]&gt;&gt;LAI_2[i]&gt;&gt;LAI_3[i]&gt;&gt;LAI_4[i]&gt;&gt;LAI_5[i]&gt;&gt;LAI_6[i];
      read&gt;&gt;LAI_7[i]&gt;&gt;LAI_8[i]&gt;&gt;LAI_9[i]&gt;&gt;LAI_10[i]&gt;&gt;LAI_11[i]&gt;&gt;LAI_12[i];
  }
  read.close();
  ofstream write;
  write.open("veg_par.txt");
  for(int j=0;j&lt;cell;j++)
  {
      write&lt;&lt;id[j]&lt;&lt;" "&lt;&lt;1&lt;&lt;endl;
      write&lt;&lt;right&lt;&lt;setw(5)&lt;&lt;crop[j]&lt;&lt;" "&lt;&lt;fixed&lt;&lt;setprecision(6)&lt;&lt;float(1)&lt;&lt;fixed&lt;&lt;setprecision(2)&lt;&lt;" "&lt;&lt;root_depth1[j]&lt;&lt;" "&lt;&lt;root_fract1[cell];
      write&lt;&lt;" "&lt;&lt;root_depth2[cell]&lt;&lt;" "&lt;&lt;root_fract2[cell]&lt;&lt;" "&lt;&lt;root_depth3[cell]&lt;&lt;" "&lt;&lt;root_fract3[cell]&lt;&lt;endl;
      write&lt;&lt;" "&lt;&lt;fixed&lt;&lt;setprecision(3)&lt;&lt;LAI_1[j]&lt;&lt;" "&lt;&lt;LAI_2[j]&lt;&lt; " "&lt;&lt;LAI_3[j]&lt;&lt;" "&lt;&lt;LAI_4[j]&lt;&lt;" "&lt;&lt;LAI_5[j]&lt;," "&lt;&lt;LAI_6[j];
      write&lt;&lt;" "&lt;&lt;LAI_7[j]&lt;&lt;" "&lt;&lt;LAI_8[j]&lt;&lt;" "&lt;&lt;LAI_9[j]&lt;&lt;" "&lt;&lt;LAI_10[j]&lt;&lt;" "&lt;&lt;LAI_11[j]&lt;&lt;" "&lt;&lt;LAI_12[j]&lt;&lt;endl;
  }
  write.close();
  }
  else
      cout&lt;&lt;"veg_par_in.txt file is missing.";
  
  }
  </code></pre>
  
  <p>The error message:</p>
  
  <pre><code>veg_par.cpp: In function ‘int main()’:
  
  veg_par.cpp:17:10: error: no match for ‘operator!=’ (operand types are ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ and                               ‘int’)
  if(read != 0)   
  veg_par.cpp:17:10: note: candidate: operator!=(int, int) &lt;built-in&gt;
  veg_par.cpp:17:10: note:   no known conversion for argument 1 from ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ to ‘in                               ’
     In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iosfwd:40:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/postypes.h:221:5: note: candidate: template&lt;class _StateT&gt; bool std::
  operator!=(const std::fpos&lt;_StateT&gt;&amp;, const std::fpos&lt;_StateT&gt;&amp;)
   operator!=(const fpos&lt;_StateT&gt;&amp; __lhs, const fpos&lt;_StateT&gt;&amp; __rhs)
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/postypes.h:221:5: note:   template argument deduction/substitution fa                              iled:  
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::fpos&lt;_StateT&gt;’
   if(read != 0)
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_algobase.h:64:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/char_traits.h:39,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_pair.h:448:5: note: candidate: template&lt;class _T1, class _T2&gt; con                              stexpr bool std::operator!=(const std::pair&lt;_T1, _T2&gt;&amp;, const std::pair&lt;_T1, _T2&gt;&amp;)
  operator!=(const pair&lt;_T1, _T2&gt;&amp; __x, const pair&lt;_T1, _T2&gt;&amp; __y)
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_pair.h:448:5: note:   template argument deduction/substitution fa                              iled:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::pair&lt;_T1, _T2&gt;’    
  if(read != 0)In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_algobase.h:67:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/char_traits.h:39,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:304:5: note: candidate: template&lt;class _Iterator&gt; bool                               std::operator!=(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_Iterator&gt;&amp;)
    operator!=(const reverse_iterator&lt;_Iterator&gt;&amp; __x,
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:304:5: note:   template argument deduction/substitutio                              n failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::reverse_iterato                              r&lt;_Iterator&gt;’
   if(read != 0)
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_algobase.h:67:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/char_traits.h:39,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:361:5: note: candidate: template&lt;class _IteratorL, cla                              ss _IteratorR&gt; bool std::operator!=(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_IteratorR&gt;&amp;)
   operator!=(const reverse_iterator&lt;_IteratorL&gt;&amp; __x,   
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:361:5: note:   template argument deduction/substitutio                              n failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::reverse_iterato                              r&lt;_Iterator&gt;’    
  if(read != 0)
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_algobase.h:67:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/char_traits.h:39,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  
   /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:1125:5: note: candidate: template&lt;class _IteratorL, cl                              ass _IteratorR&gt; bool std::operator!=(const std::move_iterator&lt;_IteratorL&gt;&amp;, const std::move_iterator&lt;_IteratorR&gt;&amp;)
   operator!=(const move_iterator&lt;_IteratorL&gt;&amp; __x,
  
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:1125:5: note:   template argument deduction/substituti                              on failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::move_iterator&lt;_                              IteratorL&gt;’
  
  if(read != 0)
             ^In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_algobase.h:67:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/char_traits.h:39,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:1131:5: note: candidate: template&lt;class _Iterator&gt; boo                              l std::operator!=(const std::move_iterator&lt;_IteratorL&gt;&amp;, const std::move_iterator&lt;_IteratorL&gt;&amp;)
   operator!=(const move_iterator&lt;_Iterator&gt;&amp; __x,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/stl_iterator.h:1131:5: note:   template argument deduction/substituti                              on failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::move_iterator&lt;_                              IteratorL&gt;’
  
   if(read != 0)
           ^
  
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/string:41:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_classes.h:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ios_base.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:42,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/allocator.h:158:5: note: candidate: template&lt;class _T1, class _T2&gt; bo                              ol std::operator!=(const std::allocator&lt;_CharT&gt;&amp;, const std::allocator&lt;_T2&gt;&amp;)
  
   operator!=(const allocator&lt;_T1&gt;&amp;, const allocator&lt;_T2&gt;&amp;)
   ^~~~~~~~
    /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/allocator.h:158:5: note:   template argument deduction/substitution f                              ailed: 
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::allocator&lt;_Char                              T&gt;’
   if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/string:41:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_classes.h:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ios_base.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:42,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/allocator.h:164:5: note: candidate: template&lt;class _Tp&gt; bool std::ope                              rator!=(const std::allocator&lt;_CharT&gt;&amp;, const std::allocator&lt;_CharT&gt;&amp;)
   operator!=(const allocator&lt;_Tp&gt;&amp;, const allocator&lt;_Tp&gt;&amp;)
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/allocator.h:164:5: note:   template argument deduction/substitution f                              ailed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::allocator&lt;_Char                              T&gt;’
   if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/string:52:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_classes.h:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ios_base.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:42,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_string.h:5112:5: note: candidate: template&lt;class _CharT, class                               _Traits, class _Alloc&gt; bool std::operator!=(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, const std::basic_string&lt;_Ch                              arT, _Traits, _Alloc&gt;&amp;)
   operator!=(const basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __lhs,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_string.h:5112:5: note:   template argument deduction/substituti                              on failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::basic_string&lt;_C                              harT, _Traits, _Alloc&gt;’
   if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/string:52:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_classes.h:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ios_base.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:42,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_string.h:5125:5: note: candidate: template&lt;class _CharT, class                               _Traits, class _Alloc&gt; bool std::operator!=(const _CharT*, const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
   operator!=(const _CharT* __lhs,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_string.h:5125:5: note:   template argument deduction/substituti                              on failed:
  veg_par.cpp:17:13: note:   mismatched types ‘const _CharT*’ and ‘std::basic_ifstream&lt;char&gt;’
  if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/string:52:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_classes.h:40,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ios_base.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:42,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_string.h:5137:5: note: candidate: template&lt;class _CharT, class                               _Traits, class _Alloc&gt; bool std::operator!=(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, const _CharT*)
   operator!=(const basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __lhs,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_string.h:5137:5: note:   template argument deduction/substituti                              on failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::basic_string&lt;_C                              harT, _Traits, _Alloc&gt;’
  if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/ios_base.h:46:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:42,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:311:3: note: candidate: bool std::operator!=(const std::error                              _code&amp;, const std::error_code&amp;)
  operator!=(const error_code&amp; __lhs, const error_code&amp; __rhs) noexcept
  ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:311:3: note:   no known conversion for argument 1 from ‘std::                              ifstream {aka std::basic_ifstream&lt;char&gt;}’ to ‘const std::error_code&amp;’
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:315:3: note: candidate: bool std::operator!=(const std::error                              _code&amp;, const std::error_condition&amp;)
  operator!=(const error_code&amp; __lhs, const error_condition&amp; __rhs) noexcept
  ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:315:3: note:   no known conversion for argument 1 from ‘std::                              ifstream {aka std::basic_ifstream&lt;char&gt;}’ to ‘const std::error_code&amp;’
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:319:3: note: candidate: bool std::operator!=(const std::error                              _condition&amp;, const std::error_code&amp;)
  operator!=(const error_condition&amp; __lhs, const error_code&amp; __rhs) noexcept
  ^~~~~~~~
   /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:319:3: note:   no known conversion for argument 1 from ‘std::                              ifstream {aka std::basic_ifstream&lt;char&gt;}’ to ‘const std::error_condition&amp;’
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:323:3: note: candidate: bool std::operator!=(const std::error                              _condition&amp;, const std::error_condition&amp;)
  operator!=(const error_condition&amp; __lhs,
  ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/system_error:323:3: note:   no known conversion for argument 1 from ‘std::                   ifstream {aka std::basic_ifstream&lt;char&gt;}’ to ‘const std::error_condition&amp;’
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_facets.h:48:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/basic_ios.h:37,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ios:44,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/ostream:38,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iostream:39,
               from veg_par.cpp:2:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/streambuf_iterator.h:210:5: note: candidate: template&lt;class _CharT, c                   lass _Traits&gt; bool std::operator!=(const std::istreambuf_iterator&lt;_CharT, _Traits&gt;&amp;, const std::istreambuf_iterator&lt;_CharT                   , _Traits&gt;&amp;)
   operator!=(const istreambuf_iterator&lt;_CharT, _Traits&gt;&amp; __a,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/streambuf_iterator.h:210:5: note:   template argument deduction/subst                   itution failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::istreambuf_iter                   ator&lt;_CharT, _Traits&gt;’
  if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/tuple:39:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:37,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_conv.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/locale:43,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iomanip:43,
               from veg_par.cpp:3:
  
  
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/array:246:5: note: candidate: template&lt;class _Tp, long unsigned int _Nm&gt; b                   ool std::operator!=(const std::array&lt;_Tp, _Nm&gt;&amp;, const std::array&lt;_Tp, _Nm&gt;&amp;)
   operator!=(const array&lt;_Tp, _Nm&gt;&amp; __one, const array&lt;_Tp, _Nm&gt;&amp; __two)
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/array:246:5: note:   template argument deduction/substitution failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::array&lt;_Tp, _Nm                    ’
  if(read != 0)
           ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:37:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_conv.h:41,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/locale:43,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iomanip:43,
               from veg_par.cpp:3:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/tuple:1367:5: note: candidate: template&lt;class ... _TElements, class ... _U                   Elements&gt; constexpr bool std::operator!=(const std::tuple&lt;_Elements ...&gt;&amp;, const std::tuple&lt;_Elements ...&gt;&amp;)
   operator!=(const tuple&lt;_TElements...&gt;&amp; __t,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/tuple:1367:5: note:   template argument deduction/substitution failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::tuple&lt;_Elements                    ...&gt;’
  if(read != 0)
             ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_conv.h:41:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/locale:43,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iomanip:43,
               from veg_par.cpp:3:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:667:5: note: candidate: template&lt;class _Tp, class _Dp, c                   lass _Up, class _Ep&gt; bool std::operator!=(const std::unique_ptr&lt;_Tp, _Dp&gt;&amp;, const std::unique_ptr&lt;_Up, _Ep&gt;&amp;)
   operator!=(const unique_ptr&lt;_Tp, _Dp&gt;&amp; __x,
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:667:5: note:   template argument deduction/substitution                    failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::unique_ptr&lt;_Tp,                    _Dp&gt;’
  if(read != 0)
             ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_conv.h:41:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/locale:43,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iomanip:43,
               from veg_par.cpp:3:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:673:5: note: candidate: template&lt;class _Tp, class _Dp&gt; b                   ool std::operator!=(const std::unique_ptr&lt;_Tp, _Dp&gt;&amp;, std::nullptr_t)
   operator!=(const unique_ptr&lt;_Tp, _Dp&gt;&amp; __x, nullptr_t) noexcept
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:673:5: note:   template argument deduction/substitution                    failed:
  veg_par.cpp:17:13: note:   ‘std::ifstream {aka std::basic_ifstream&lt;char&gt;}’ is not derived from ‘const std::unique_ptr&lt;_Tp,                    _Dp&gt;’
  if(read != 0)
             ^
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/locale_conv.h:41:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/locale:43,
               from /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/iomanip:43,
               from veg_par.cpp:3:
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:678:5: note: candidate: template&lt;class _Tp, class _Dp&gt; b                   ool std::operator!=(std::nullptr_t, const std::unique_ptr&lt;_Tp, _Dp&gt;&amp;)
   operator!=(nullptr_t, const unique_ptr&lt;_Tp, _Dp&gt;&amp; __x) noexcept
   ^~~~~~~~
  /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/bits/unique_ptr.h:678:5: note:   template argument deduction/substitution                    failed:
  veg_par.cpp:17:13: note:   mismatched types ‘const std::unique_ptr&lt;_Tp, _Dp&gt;’ and ‘int’
  if(read != 0)
           ^
  veg_par.cpp:34:109: error: expected primary-expression before ‘,’ token
  write&lt;&lt;" "&lt;&lt;fixed&lt;&lt;setprecision(3)&lt;&lt;LAI_1[j]&lt;&lt;" "&lt;&lt;LAI_2[j]&lt;&lt; " "&lt;&lt;LAI_3[j]&lt;&lt;" "&lt;&lt;LAI_4[j]&lt;&lt;" "&lt;&lt;LAI_5[j]&lt;," "&lt;&lt;LAI_6[j                   ];
                                                                                                           ^
  veg_par.cpp:34:113: error: invalid operands of types ‘const char [2]’ and ‘double’ to binary ‘operator&lt;&lt;’
  write&lt;&lt;" "&lt;&lt;fixed&lt;&lt;setprecision(3)&lt;&lt;LAI_1[j]&lt;&lt;" "&lt;&lt;LAI_2[j]&lt;&lt; " "&lt;&lt;LAI_3[j]&lt;&lt;" "&lt;&lt;LAI_4[j]&lt;&lt;" "&lt;&lt;LAI_5[j]&lt;," "&lt;&lt;LAI_6[j                   ];
                                                                                                            ~~~^~~~~~~~~                   ~
  </code></pre>
  
  <p>The first error says there is no match for 'operator!=' with operand types char and int. I have been looking into this error and found out this may be related with the operator comparing two types of operand types. Here, 'read' is a stream variable and it has a data type of char and the operator is comparing two data types. I am pretty sure that all the errors while running this code arises from the operator comparing the two data types.</p>
  
  <p>I used "g++ -g veg_par.cpp -o a.exe" for compilation.</p>
  
  <p>How do I solve this error? Any help would be highly appreciated.</p>