[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#171561: help needed with Debian report -- forwarded message from Francesco Potorti`



"Martin v. Löwis" writes:
> > Sorry if this is not a bug, but I cannot find any way why it isn't.  
> [...]
> > bin2a.cc: In function `int main(int, char**)':
> > bin2a.cc:9: `cerr' undeclared (first use this function)
> 
> It is not a bug, cerr is really not a predefined identifier in C++. What 
> you mean is std::cerr.

yes, I changed this, but got:

$ g++-3.2 bug-171561.cc
bug-171561.cc: In function `int main(int, char**)':
bug-171561.cc:14: `bin' is not a member of type `std::basic_ios<char, 
   std::char_traits<char> >'
bug-171561.cc:17: no matching function for call to `std::basic_ifstream<char, 
   std::char_traits<char> >::read(double*, unsigned int)'
/usr/include/c++/3.2/bits/istream.tcc:778: candidates are: 
   std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, 
   _Traits>::read(_CharT*, int) [with _CharT = char, _Traits = 
   std::char_traits<char>]

#include <iostream>
#include <fstream>

// Leggi da file in binario e scrivi su standard input in ascii
int
main (int argc, char *argv[])
{
  if (argc != 2)
    {
      std::cerr << "Un argomento richiesto: nome del file di ingresso\n";
      exit (1);
    }

  std::ifstream f (argv[1], ios::bin | std::ios::in);
  double x;

  while (f.read(&x, sizeof(x)))
    std::cout << x << '\n';
  return 0;
}



Reply to: