发生错误无法弄清楚 [英] Error occured can't figure out
本文介绍了发生错误无法弄清楚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是代码段
Here is the code snippet
v1=fopen("Input.txt","r");
getline(v1,c);
while ( v1 )
{
ch += c;
getline(v1,c);
}
我收到错误
没有重载函数的实例getline匹配参数列表
参数类型是:(FILE *,std :: string)
而v1是文件指针而c是字符串.....
I get an error
"no instance of overloaded function "getline" matches the argument list
argument types are: (FILE *, std::string)"
while the v1 is file pointer and c is the string.....
推荐答案
如果我是你,我会仔细查看fopen
(打开文件的函数) C运行时库)和getline
(从 C ++运行时库中读取一行文本的函数)实际做。
基本上你必须选择一个IO模型(基于C的FILE指针/函数的API或C ++的流/运算符)基于/函数的API)并且不要混合两者。
If I were you I'd look very carefully at whatfopen
(the function that opens a file in the C runtime library) andgetline
(the function that reads a line of text from a stream in the C++ runtime library) actually do.
Basically you have to pick an IO model (either C's FILE pointer/function based API or C++'s stream/operator/function based API) and don't mix the two.
你试过这个:
http://www.cplusplus.com/forum/beginner/11304/ [ ^ ]
这篇关于发生错误无法弄清楚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文