a naive question about the exception in fstream
From: Newsgroup - Ann (news_ann_at_yahoo.com)
Date: 10/29/03
- Previous message: Jack Klein: "Re: C++: compiling header files"
- Next in thread: Davlet Panech: "Re: a naive question about the exception in fstream"
- Reply: Davlet Panech: "Re: a naive question about the exception in fstream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Oct 2003 21:25:29 -0500
The fstream is supposed to be a replacement of the stdio.h and the exception
is supposed to be a replacement of the return error code. So how do I
replace my old codes of the style:
if (output = fopen(...) == NULL) {
perror("...");
exit(1);
}
by the C++ style? The only thing I can do now is like
fstream output("...", ios_base::out);
if (!output.is_open()) {
cerr << "..." << endl;
exit(1);
}
how do I use exception here? Or I should not?
Ann
- Previous message: Jack Klein: "Re: C++: compiling header files"
- Next in thread: Davlet Panech: "Re: a naive question about the exception in fstream"
- Reply: Davlet Panech: "Re: a naive question about the exception in fstream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading