Reputation: 171
I'm trying to parse a document using getline to take an entire line and place it in the string variable named 'line.' The problem is I'm getting an error that says: "No instance of overloaded function getline matches the argument list." Can anyone help me solve this problem?
#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);
}
Upvotes: 1
Views: 1437
Reputation: 372684
Your escape sequence is backward - try replacing
/n
With
\n
Multicharacter character liberals in C++ have type int
, rather than type char
, which is causing the arguments to std::getline
to have the wrong type. (Thanks to @chris for pointing out that the type will be int
specifically!)
Hope this helps!
Upvotes: 6