| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1326 人关注过本帖
标题:这个错误是为啥?怎样改正?
只看楼主 加入收藏
冷月·葬花魂
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-12-10
结帖率:75%
收藏
 问题点数:0 回复次数:3 
这个错误是为啥?怎样改正?
d:\专业\vc6\myprojects\行文本编辑器\行文本编辑器3\linklist.h(66) : error C2664: '__thiscall fstream::fstream(int)' : cannot convert parameter 1 from 'char [12]' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
        d:\专业\vc6\myprojects\行文本编辑器\行文本编辑器3\linklist.h(63) : while compiling class-template member function 'void __thiscall LinkList<char>::Showwenben(void)'
Error executing cl.exe.
代码如下
void Showwenben()//显示当前文本
    {
        cout<<"当前文本是:"<<endl;
        int i,j;
        fstream examplefile("example.txt");//错误行
        for(i=0;i<hang;i++)
        {
            
            for(j=0;j<lie;j++)
            {
                cout<<wenben[i][j];
                if (examplefile.is_open())
                {
                    examplefile<<"wenben[i][j]";
                    
                }
               
            }
            examplefile.close();
            cout<<endl;
        }
    }
};
搜索更多相关主题的帖子: 错误 文本编辑器 int void cout 
2018-06-26 15:11
Myloop
Rank: 2
来 自:湖北随州
等 级:论坛游民
威 望:2
帖 子:18
专家分:27
注 册:2017-10-21
收藏
得分:0 
你这个函数是想先在控制台输出wenben数组的某个元素然后将该元素写入到文件中,是吗

Myloop
Speak is cheap,show me the code.
2018-06-26 23:15
Jonny0201
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:52
帖 子:488
专家分:2603
注 册:2016-11-7
收藏
得分:0 
我这里运行没错
fstream::fstream(int)
你编译器上的 fstream 是这样的
根据你编译器的具体实现对症下药
2018-06-27 10:27
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:0 
回复 3楼 Jonny0201
题主用的 VC6,fstream.h中的标准头
fstream examplefile("example.txt"); 改为 fstream examplefile("example.txt",ios::out); 或许可以
2018-06-27 11:00
快速回复:这个错误是为啥?怎样改正?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021640 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved