I have a question about using ifstream.
From text book, it tells me we can use like following
(1)
Code:
ifstream infile;
infile.open("abc.txt");
if(!infile)
cerr << "Error: uanable to open input file" << endl;
(2)
However, I just codes from some others using ifstreams*..
and I modify (1) to
Code:
ifstream* infile;
infile->open("abc.txt");
if(!(*infile))
cerr << "Error: uanable to open input file" << endl;
Both pass compiling process, but somehow if abc.txt doesn't exist, then
(1) shows the correct cerr message
(2) shows "Segmenation fault"
Actually I don't quite get the meaning of fstream
Isn't (2) same as (1)?
Can I think of ifstream like a file pointer? Then it reads EOF or other error which returns false value in if(infile).. And ifstream* is a pointer pointer to a file pointer?