1. C++ Fstream Ios
C++ fstream api
2000-10-30 23:00:38 UTC
Hello, I am new to C++.
I am following a tutorial in wich it appears the following code (wich makes
a copy of a file):
#include <iostream.h>
#include <fstream.h>
#include <process.h>
void main()
{
ifstream infile;
ofstream outfile;
char filename[20];
cout << 'Enter the desired file to copy ----> ';
cin >> filename;
infile.open(filename, ios::nocreate);
if (!infile) {
cout << 'Input file cannot be opened.n';
exit(1);
}
outfile.open('copy');
if (!outfile) {
cout << 'Output file cannot be opened.n';
exit(1);
}
char one_char;
while (infile.get(one_char)) {
outfile.put(one_char);
cout.put(one_char);
}
infile.close();
outfile.close();
}
It should create a copy of the original file into the file 'COPY'. The
program compiles and runs properly but the file COPY is empty (it exists but
has 0 bytes), what is wrong?
thanks. Esteban

C++ Fstream Ios

Free Download Iostream.h For Dev C. The C Standard Library. May 20, 2017 iostream.h is not a standard header file (if anything supports it, it's for backward compatibility from long ago). Use iostream instead. None of the header files introduced in C. The C STL Library. Nov 09, 2016 Java Project Tutorial - Make Login and Register Form.