cpp program returns core dumped while reading csv file

  c++, csv, file, vector

I am trying to make a program that reads csv file and set the format in a 2d vector of string so as to use in my project.It says nothing and gives strange errors saying core dumped.

#include<iostream>
#include<vector>
#include<fstream>
using namespace std;
class pk{
    public:
    vector <string> func1(string a){
        string temp="";
        int k=0;
        vector<string> finalone;
        for(int i=0;i<sizeof(a)/sizeof(a[0]);i++){
            if (a[i]==','){
                finalone.push_back(temp);
                temp="";
                k=0;
                continue;
            }
            temp[k]=a[i];
            k+=1;


        }
        return finalone;

    }
};
int main(){
    fstream f1;
    string line;
   vector< vector <string>> p;
    f1.open("pk.txt");
    while (f1){
getline(f1,line);
pk puj;
p.push_back(puj.func1(line));

    }


}

here is the error:
/usr/include/c++/10.2.0/ostream:773:5: error: no type named ‘type’ in ‘struct std::enable_if<false, std::basic_ostream&>’
and it gives more strange errors saying core dumped at last.

Source: Windows Questions C++

LEAVE A COMMENT