首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

文件读取为什么东东

2012-03-02 
文件读取为什么错误?#includeiostream#includefstreamusingnamespacestdintmain(){ofstreammyfile(

文件读取为什么错误?
#include   <iostream>  
#include   <fstream>  
using   namespace   std;  
int   main()    
{  
                ofstream   myfile( "mike.txt ",ios_base::app,0);  
                if(!myfile)//或者写成myfile.fail()  
                {  
                                cout < < "文件打开失败,目标文件状态可能为只读! ";  
                                system( "pause ");  
                                exit(1);  
                }  
                myfile < < "中国软件开发实验室 " < <endl < < "网址: " < < "www.cndev-lab.com " < <endl;  
//cin.get();
                myfile.close();  
               
                return   0;
}  
no   matching   function   for   call   to   `std::basic_ofstream <char,   std::char_traits <char>   > ::basic_ofstream(const   char[9],   const   std::_Ios_Openmode&,   int) '   。。。。

[解决办法]
ofstream( const char *filename, openmode mode );
应该只有2个参数啊
[解决办法]
ofstream myfile( "mike.txt ",ios_base::app,0);
==》
ofstream myfile( "mike.txt ",ios_base::app);
[解决办法]
ofstream( const char *filename, openmode mode );

没有第三个参数 ~
[解决办法]
应该就是这个问题了.
[解决办法]
应该解决了吧。
[解决办法]
对就是要两个参数的
[解决办法]
找了半天。
在windows下
原来第三个参数是控制共享访问方式的。只允许以下几个值:
0x10 //_SH_DENYRW Denies read and write access to the file
0x20 //_SH_DENYWR Denies write access to the file
0x30 //_SH_DENYRD Denies read access to the file.
0x40 //_SH_DENYNO Permits read and write access
其他值都会抱 "Invalid sharing flag "的错误。

热点排行