Good evening.
I'm trying to copy a text file (original_file) to a new file(new_file), my problem is that I need the content to be exactly the same in the new file, but the code I use now skips end of lines, and blank space (" ".
My code:
char read_str;
ifstream read_file("original_file", ios::nocreate);
if(!read_file.fail())
{
ofstream write_file("new_file", ios::nocreate);
write_file.setmode(filebuf::text);
if(!write_file.fail())
{
while(!read_file.eof())
{
read_file >> read_str;
write_file << read_str;
}
read_file.close();
write_file.close();
}
}
Greets CetGabbe.
I'm trying to copy a text file (original_file) to a new file(new_file), my problem is that I need the content to be exactly the same in the new file, but the code I use now skips end of lines, and blank space (" ".
My code:
char read_str;
ifstream read_file("original_file", ios::nocreate);
if(!read_file.fail())
{
ofstream write_file("new_file", ios::nocreate);
write_file.setmode(filebuf::text);
if(!write_file.fail())
{
while(!read_file.eof())
{
read_file >> read_str;
write_file << read_str;
}
read_file.close();
write_file.close();
}
}
Greets CetGabbe.