ios::nocreate和ios::noreplace

来源:互联网 发布:anyview java 编辑:程序博客网 时间:2024/05/22 17:47
The ios::nocreate setting did not make it into the ISO 14882:1998 C++
     standard. Too platform specific.

     You can simulate that behavior with:

     fstream foo("foo.txt", ios_base::in);
     if(!fs) {
   // File does not exist.
   // Do not create one.
    }
    else {
    foo.close();
   foo.open("foo.txt", ios_base:ut);
}

ios::nocreate:打开一个以有的文件,如文件不存在,则打开失败,nocreate的意思是不建立新文件

ios::noreplace:如果文件不存在则建立新文件,如果文件以存在则操作失败,noplace的意思是不建立新文件

在新版本的C++系统I/O类库中不提供ios::nocreat和ios::noreplace

用ios_base::in|ios_base::on可做判断

"书山有路勤为径 ,学海无涯苦作舟"   出自我国唐代著名诗人、哲学家韩愈的治学名联。

人的一生这么短,还是做自己喜欢的事比较好.......比如 不学习C++     哈哈哈