1

getline を使用してドキュメントを解析し、行全体を取得して「line」という名前の文字列変数に配置しようとしています。問題は、「オーバーロードされた関数 getline のインスタンスが引数リストと一致しません」というエラーが表示されることです。誰でもこの問題を解決するのを手伝ってもらえますか?

#include <iostream>
#include <fstream>
#include <string>
#include "recordsOffice.h"

using namespace std;

RecordsOffice::RecordsOffice()
{

}

void RecordsOffice::parseCommands (string commandsFileName)
{
//String to hold a line from the file
string line;

//Open the file
ifstream myFile;
myFile.open(commandsFileName);

// Check to make sure the file opened properly
if (!myFile.is_open())
{
    cout << "There was an error opening " << commandsFileName << "." << endl;
    return;
}

//Parse the document
while (getline(myFile, line, '/n'))
{
    if (line[0] == 'A')
    {
        addStudent(line);
    }
4

1 に答える 1

6

エスケープ シーケンスが逆です - 置き換えてみてください

/n

\n

C++ の複数文字リベラルには、 typeintではなく typecharがあり、引数std::getlineの型が間違っています。(タイプが具体的になることを指摘してくれた@chrisに感謝しますint!)

お役に立てれば!

于 2013-02-02T02:26:57.347 に答える