Hi,
I'v written a small program which simulates the DOS command "type". The =20
program receives
a file name form the command line. I used "fail()" function to check =20
existence of the received
file. I have not used "ifstream" functions a lot and I want to know =20
whether this is the
proper way to do so or not.
There is another function called "bad()". Please tell me what kind of =20
errors it can detect.
I tried it in my program and it couldn't check existence of files.
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
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");
}
Thanks.
--=20
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
|