Thread: [Dev-C++] Re: Dev-cpp-users digest, Vol 1 #34 - 1 msg
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Softhome <ma...@so...> - 2000-11-06 20:07:22
|
Hi, I suggest to change line: > infile.open(filename, ios::nocreate); to: > infile.open(filename, ios::nocreate | ios::in); // read enable Regards Marceli ----------------------------------------------------- Click here for Free Video!! http://www.gohip.com/free_video/ ----- Original Message ----- From: <dev...@li...> To: <dev...@li...> Sent: Wednesday, November 01, 2000 9:08 AM Subject: Dev-cpp-users digest, Vol 1 #34 - 1 msg > Send Dev-cpp-users mailing list submissions to > dev...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > or, via email, send a message with subject or body 'help' to > dev...@li... > > You can reach the person managing the list at > dev...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Dev-cpp-users digest..." > > > Today's Topics: > > 1. get (=?iso-8859-1?Q?Esteban_Cresp=ED_de_Valldaura?=) > > --__--__-- > > Message: 1 > From: =?iso-8859-1?Q?Esteban_Cresp=ED_de_Valldaura?= <ec...@re...> > To: <dev...@li...> > Date: Tue, 31 Oct 2000 00:00:38 +0100 > charset="iso-8859-1" > Subject: [Dev-C++] get > Reply-To: dev...@li... > > 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 > > > > --__--__-- > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > > > End of Dev-cpp-users Digest_______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > |
|
From: lstar36 <ls...@fl...> - 2000-11-07 02:36:41
|
Your program compiles and runs fine on my system. I am using borland c++ Ver 3.1. The change sugested below should not cause any change as the default is to open in read mode. ----- Original Message ----- From: "Softhome" <ma...@so...> To: <dev...@li...> Sent: Monday, November 06, 2000 2:29 AM Subject: [Dev-C++] Re: Dev-cpp-users digest, Vol 1 #34 - 1 msg > Hi, > I suggest to change line: > > infile.open(filename, ios::nocreate); > to: > > infile.open(filename, ios::nocreate | ios::in); // read enable > > Regards > Marceli > ----------------------------------------------------- > Click here for Free Video!! > http://www.gohip.com/free_video/ > > ----- Original Message ----- > From: <dev...@li...> > To: <dev...@li...> > Sent: Wednesday, November 01, 2000 9:08 AM > Subject: Dev-cpp-users digest, Vol 1 #34 - 1 msg > > > > Send Dev-cpp-users mailing list submissions to > > dev...@li... > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > > or, via email, send a message with subject or body 'help' to > > dev...@li... > > > > You can reach the person managing the list at > > dev...@li... > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of Dev-cpp-users digest..." > > > > > > Today's Topics: > > > > 1. get (=?iso-8859-1?Q?Esteban_Cresp=ED_de_Valldaura?=) > > > > --__--__-- > > > > Message: 1 > > From: =?iso-8859-1?Q?Esteban_Cresp=ED_de_Valldaura?= <ec...@re...> > > To: <dev...@li...> > > Date: Tue, 31 Oct 2000 00:00:38 +0100 > > charset="iso-8859-1" > > Subject: [Dev-C++] get > > Reply-To: dev...@li... > > > > 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 > > > > > > > > --__--__-- > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > > > > > > End of Dev-cpp-users Digest_______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > |