This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug in istream.get(b,c,d) ?


Loren James Rittle wrote:
...
Consider (line at a time version of cat
which alway adds a final newline if not present):
Or even easier and more efficient:

#include <iostream>
#include <fstream>

int main (int argc, char *argv[])
{
    for (int i = 1; i < argc; ++i)
        std::cout << std::ifstream (argv [i], std::ios::in).rdbuf ();
}

Regards
Martin

#include <iostream>
#include <fstream>
#include <string>

int
main (int argc, char *argv[])
{
  std::string s;
  for (int i = 1; i < argc; i++)
    {
      std::ifstream file(argv[i], std::ios::in);

      while (getline (file, s))
        std::cout << s << std::endl;
    }
}

Regards,
Loren



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]