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

Martin Sebor sebor@roguewave.com
Wed Sep 18 15:43:00 GMT 2002


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





More information about the Libstdc++ mailing list