|
From: Robert A. <ral...@gm...> - 2005-05-19 13:00:15
|
Check out... http://www.cplusplus.com/ref/#libs Then look at fstream and the clear function( which actually sets/clears statuses).... Hope this helps, Robert On 5/20/05, Farzan Hajian <far...@ho...> wrote: > Hi, > I'v written a small program which simulates the DOS command "type". The > program receives > a file name form the command line. I used "fail()" function to check > existence of the received > file. I have not used "ifstream" functions a lot and I want to know > whether this is the > proper way to do so or not. > There is another function called "bad()". Please tell me what kind of > errors it can detect. > I tried it in my program and it couldn't check existence of files. >=20 > #include <iostream> > #include <fstream> > #include <cstdlib> >=20 > using namespace std; >=20 > int main(int argc,char* arg[]) > { > if(argc=3D=3D2) > { > ifstream File(arg[1]); > char ch; > if(File.fail()) > cout << "File not found!\n"; > else > while(true) > { > File.get(ch); > if(File.eof()) > break; > cout << ch; > } > } > system("pause>null"); > } >=20 > Thanks. >=20 >=20 > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_idt12&alloc_id=16344&opclick > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |