0
我無法找出一個文件istream的函數getline正確的語法()調用C++ - 不爲調用「函數getline」匹配功能
我已經打過電話getline()
與各種不同類型的參數,那麼多的變化和在查看幾個不同的文檔之後,它就不起作用了。
std::ifstream in("file.txt");
char tmp;
std::getline(tmp, in);
這一個結果
../directory/file.cpp:178:2: error: no matching function for call to 'getline'
std::getline(tmp, in);
^~~~~~~~~~~~
但其他文件說
std::ifstream in("file.txt");
char tmp;
in.getline(tmp);
也吐出
../directory/file.cpp:179:5: error: no matching member function for call to
'getline'
in.getline(tmp);
^~~~~~~~~~~~
所有我需要做的就是讀取文件中的行按行,我無法弄清楚。有人能指點我正確的方向嗎?如果需要,我可以提供更多信息。
你檢查[文檔](http://en.cppreference.com/w/cpp/string/basic_string/getline)? – EdChum
個人而言,當我遇到函數語法的問題時,[**我在線查找語法](http://en.cppreference.com/w/cpp/string/basic_string/getline)。你應該使用'std :: string'的函數形式。 –
@EdChum我已經引用了這個http://www.cplusplus.com/reference/istream/istream/getline/現在檢查你的資源 – conjenks