How to use getline() correct

Following code causes me some problems and I really don't know why:

#include<iostream>
#include<string>
#include <cstring>
#include<cmath>
#include<vector>
#include <fstream>


using namespace std;


int main()
{
string filename = "myfile.csv";
ifstream file (filename);
vector<string> store;
string read;
int q = 0;


if(file.is_open())
{
cout<<"file open"<<endl;
while(getline(file,read,";"))
{

q++;
store.push_back(read);
cout<<read<<endl;
}

for(int i = 0; i<=q; i++)
{


cout<<store[i]<<"i: "<<i<<endl;
}

}
else{cout<<"file not found"<<endl;}

cout<<store[1]<<endl;

return 0;
}

So I try to read a file and seperate it from its semicolons.
I always get the error:
error: no matching function for call to ‘getline(std::__cxx11::string&, std::__cxx11::string&, const char [2])’
The third argument should be a char, not a string.

 
getline(file, read, ';')
I see.... Is there a way to work arround this problem or is there a getline() function for strings?
gamma wrote:
Is there a way to work arround this problem

It isn't a problem. You simply use single quotes in the third argument, not double quotes. Exactly as @Peter87 has shown you.
Sorry. I thought you meant that a semicolon is not interpreted by the compiler as a char.
Thanks for your help.
Topic archived. No new replies allowed.