I have some table of data in a '.csv' file.I want to push those data from that file to a vector.I tried push_back.But it hasn't worked for me.I'm actually a beginner to c++.Could someone help me to sort this out?
struct contacts {
string name;
string nickName;
string phoneNumber;
string carrier;
string address;
};
vector <contacts> proContactFile;
Here is the part I read values from the file(Below)
void readContactDetails() {
ifstream ContactFile;
ContactFile.open("Contact.csv");
string readString;
if (ContactFile) {
while (!(ContactFile.eof())) {
getline(ContactFile, readString); // Read the column headers
for (int i = 0; i <= 10; i++) {
getline(ContactFile, limit[i].name, ','); // ',' is the separator
getline(ContactFile, limit[i].nickName, ',');
getline(ContactFile, limit[i].phoneNumber, ',');
getline(ContactFile, limit[i].carrier, ',');
getline(ContactFile, limit[i].address); // Read until the end of the line
}
proContactFile.push_back(ContactFile);
}
}
else {
cout << "Error"<< endl;//Show an error message if the file isn't opened
}
}
It always shows the error message ->
no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=contacts, _Alloc=std::allocator<contacts>]" matches the argument list
Could someone tell me whats wrong with this?