473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

copy a file

hi!

i'm trying to copy a file with the std::copy function but my problem is,
that whitespaces are discarded. could anyone tell me how i can just copy all
the characters that are in the source-file. thx.

std::istream_iterator<std::string> ins(in), eos;
std::ostream_iterator<std::string> outs(out);
std::copy(ins, eos, outs);

thanks,
sev
Jul 22 '05 #1
2 1752

"Severin Ecker" <se****@gmx.at> wrote in message news:3f***********************@aconews.univie.ac.a t...
hi!

i'm trying to copy a file with the std::copy function but my problem is,
that whitespaces are discarded. could anyone tell me how i can just copy all
the characters that are in the source-file. thx.

std::istream_iterator<std::string> ins(in), eos;
std::ostream_iterator<std::string> outs(out);
std::copy(ins, eos, outs);

You can have the ostream_iterator output a separator if you give it a second
arg:
std::ostream_iterator<std::string> outs(out,'\n');

Do you really want to be doing formatted I/O?
If you want to literally copy the file, it's probably better to use use a loop of
read/write combintations (or getline at the worst).

Jul 22 '05 #2

"Severin Ecker" <se****@gmx.at> wrote in message
news:3f***********************@aconews.univie.ac.a t...
hi!

i'm trying to copy a file with the std::copy function but my problem is,
that whitespaces are discarded. could anyone tell me how i can just copy all the characters that are in the source-file. thx.

std::istream_iterator<std::string> ins(in), eos;
std::ostream_iterator<std::string> outs(out);
std::copy(ins, eos, outs);

thanks,
sev


std::ifstream In(SrcFilename, std::ios::binary);
std::ofsteam Out(DstFilename, std::ios::binary);

Out << In.rdbuf();

Voilà
This will make an exact copy of the input file.

Tanguy
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Claudio Grondi | last post by:
I would like to save time copying the same file (>6 GByte) to various different target storage media connected to the system via USB. Is there a (Python or other) tool able to help me to do...
0
by: SeanR | last post by:
I have a function to copare two files. It will first copy the original file form a different server to a local temp path and then compare that version to a version that has been restored form tape....
0
by: Joshua Ginsberg | last post by:
Howdy -- I have a class that has an attribute that is a dictionary that contains an object that has a kword argument that is a lambda. Confused yet? Simplified example: import copy class...
5
by: DraguVaso | last post by:
Hi, I need a SECURE way to copy parts of a file. I'm having files which contains a whole bunch of records. In one 'fysical' file I'm having one or more logical files. What I need to do is to...
8
by: luis molina Micasoft | last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make 40 threads of file.copy , 40 copys of files at same time the system is going down and stop responding, this is when i'm...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
4
by: Emin | last post by:
Dear experts, I got some unexpected behavior in getattr and copy.deepcopy (see transcript below). I'm not sure if this is actually a bug in copy.deepcopy or if I'm doing something too magical...
1
by: ajc308 | last post by:
I'm attempting to sort the <file>s within each <directory> in my XML according to their file extension, then write out the resulting sorted data back to XML format. I had it working before, and when...
3
by: maheshkadam | last post by:
Hi friends I am new to perl so please guide me. I have one application which created backup log file every day.But it appends that file so you can see logs for different day in one file only. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.