Article View: alt.comp.lang.learn.c-c++
Article #200Re: IO
From: Thomas
Date: Thu, 24 Dec 1998 00:00
Date: Thu, 24 Dec 1998 00:00
57 lines
1895 bytes
1895 bytes
There are many examples of copying files.
Please use a newsreader to search the newsgroups for examples.
A free newsreader can be found at http://www.dejanews.com
Here are some examples.
Prolog
------
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
const int MAX_BUFFER_SIZE = 10240; // 10k
unsigned char buffer[MAX_BUFFER_SIZE];
File Copy Procedures
--------------------
void File_Copy_1(istream& inp, ostream& out)
{
out << inp;
return;
}
void File_Copy_2(istream& inp, ostream& out)
{
while (inp.good())
{
inp.read(buffer, MAX_BUFFER_SIZE);
out.write(buffer, inp.gcount());
}
return;
}
void File_Copy_3(const char * const input_filename,
const char * const output_filename)
{
char sys_copy_cmd[256];
if (input_filename && output_filename)
{
sprintf(sys_copy_command, "copy %s %s\n",
input_filename, output_filename);
system(sys_copy_cmd);
}
return;
}
void File_Copy_4(const char * const input_filename,
const char * const output_filename)
{
// Use operating system calls to copy a file
}
--
Thomas Matthews
email: matthto@stamps.stortek.com
Technical Details
Message-ID:
<368275D0.5DFEEF5C@atlantis.stortek.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<368245b7.0@news.newsfeeds.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114592,d0a4b58b51fa9ad7 X-Google-Attributes: gid114592,public X-Google-Thread: 109fba,d0a4b58b51fa9ad7 X-Google-Attributes: gid109fba,public X-Google-Thread: 10d4ba,d0a4b58b51fa9ad7 X-Google-Attributes: gid10d4ba,public From: Thomas <matthto@atlantis.stortek.com> Subject: Re: IO Date: 1998/12/24 Message-ID: <368275D0.5DFEEF5C@atlantis.stortek.com> X-Deja-AN: 425547223 Content-Transfer-Encoding: 7bit References: <368245b7.0@news.newsfeeds.com> Content-Type: text/plain; charset=us-ascii Organization: StorageTek Corporation Mime-Version: 1.0 Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++