Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Error Opening multiple files

Reply
Thread Tools

Error Opening multiple files

 
 
BB
Guest
Posts: n/a
 
      12-20-2003
Im trying to write a piece of code to open all files in the current
directory, read their contents and write it out to another file.
However after the program runs the output files are not there. Through
debugging I know the (output)files are being opened and the info. is being
wrote to them. But there is no files anywhere when the program finishes??
A piece of code used:

while( _findnext( hSearch, &FileData ) == 0 )
{
cout<<"FILE "<<FileData.name;
wFileIn.clear();

wFileIn.open(FileData.name,ios::in||ios::binary);
if(!wFileIn.is_open())
{
cout<<"File "<<FileData.name<<" could not be opened"<<endl;

}
else
{

getOutputFile(FileData.name,wOut);//gets the name of output file
wFileOut.clear();
wFileOut.open(wOut,ios::in||ios:ut||ios::binary) ;

//read in data
//...

for(int i = 0;i < 27;i++)
wFileOut<<i;


wFileIn.close();
wFileOut.close();


}


}
_findclose( hSearch );
exit(0);

Thanks


 
Reply With Quote
 
 
 
 
David Harmon
Guest
Posts: n/a
 
      12-20-2003
On Sat, 20 Dec 2003 15:56:04 -0000 in comp.lang.c++, "BB"
<(E-Mail Removed)> was alleged to have written:
> wFileIn.open(FileData.name,ios::in||ios::binary);
> if(!wFileIn.is_open())
> {
> cout<<"File "<<FileData.name<<" could not be opened"<<endl;


if (!wFileIn)
perror(Filedata.name);

> getOutputFile(FileData.name,wOut);//gets the name of output file
> wFileOut.clear();
> wFileOut.open(wOut,ios::in||ios:ut||ios::binary) ;


if (!wFileOut)
perror(wOut);

 
Reply With Quote
 
 
 
 
David Harmon
Guest
Posts: n/a
 
      12-20-2003
On Sat, 20 Dec 2003 17:31:43 GMT in comp.lang.c++, David Harmon
<(E-Mail Removed)> was alleged to have written:
>On Sat, 20 Dec 2003 15:56:04 -0000 in comp.lang.c++, "BB"
><(E-Mail Removed)> was alleged to have written:
>> wFileIn.open(FileData.name,ios::in||ios::binary);


Oops, did not spot that the first time through!
Should be:
wFileIn.open(FileData.name, ios::in|ios::binary);

Use | for or-ing bits and flags.
Use || for or-ing true false bools;


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening multiple Files in Different Encoding Subhabrata Python 5 07-11-2012 11:22 PM
opening multiple files familyofamin@gmail.com Computer Support 1 03-27-2006 08:09 AM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
Error opening web project on pc with multiple sites Brad ASP .Net 5 05-18-2004 12:14 AM
Opening and Printing Multiple Files fkissam Computer Support 1 05-06-2004 05:39 PM



Advertisments