🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #201

Re: IO

#201
From: Michael J. Tobler
Date: Sun, 27 Dec 1998 00:00
43 lines
1687 bytes
In article <368245b7.0@news.newsfeeds.com>, merc@toughguy.net says...
> hi...  can any write a little short function using <iostream> to read in any
> kind of file and make a copy of it
> 
> I'm learning IO here but I need some good examples...  thanks

#include <iostream>
int main( int argc, char **argv )
{
  std::cout << std::cin.rdbuf( ) ;

  return 0 ;
}

Use redirection on the command line :)
or

#include <iostream>
#include <fstream>
int main( int argc, char **argv )
{
  // error processing for command line args left out
  ...

  std::ifstream in( "filename.in", std::ios::in ) ;
  std::ofstream out( "filename.out", std::ios::out ) ;

  // error processing for file open left out
  ...

  out << in.rdbuf( ) ;

  return 0 ;
}



-- 
<<<<<<<<<<  Blue Skies  >>>>>>>>>>>
<        Michael J. Tobler        >
<     mtobler@no-spam-ibm.net     >
< remove "no-spam-" when replying >
<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
Technical Details
Message-ID: <MPG.10ef8b2724d51bb989f3f@news3.ibm.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <368245b7.0@news.newsfeeds.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,d0a4b58b51fa9ad7
X-Google-Attributes: gid109fba,public
X-Google-Thread: 10d4ba,d0a4b58b51fa9ad7
X-Google-Attributes: gid10d4ba,public
X-Google-Thread: 114592,d0a4b58b51fa9ad7
X-Google-Attributes: gid114592,public
From: mtobler@no-spam-ibm.net (Michael J. Tobler)
Subject: Re: IO
Date: 1998/12/27
Message-ID: <MPG.10ef8b2724d51bb989f3f@news3.ibm.net>
X-Deja-AN: 426095521
References: <368245b7.0@news.newsfeeds.com>
X-Notice: should be reported to postmaster@ibm.net
X-Complaints-To: postmaster@ibm.net
X-Trace: 27 Dec 1998 06:30:38 GMT, 32.100.175.220
Organization: MJT
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++