I am trying to create a function in my c++ program which reads in strings from a file and assigns them to a variable then passes these variables into an object constructor which is then added to a vector<object>. So far this is what I have:
ifstream load;
string s1="",s2="",s3="";
load.open("myFile.txt");
while(! load.eof())
{
getline(load, s1, " ");
getline(load, s2, " ");
getline(load, s3, " ");
Object newObj(s1,s2,s3);
list.push_back(newObj);
}
load.close();
The error i keep getting is an invalid conversion from void* to char** This error seems to occur in the getline function's second parameter. I am a little new to c++ programming and I am not sure what parameters are supposed to be passed to it. the file it is reading from has every variable separated by a single space.
Any help will be greatly appreciated.
Thanks.
ifstream load;
string s1="",s2="",s3="";
load.open("myFile.txt");
while(! load.eof())
{
getline(load, s1, " ");
getline(load, s2, " ");
getline(load, s3, " ");
Object newObj(s1,s2,s3);
list.push_back(newObj);
}
load.close();
The error i keep getting is an invalid conversion from void* to char** This error seems to occur in the getline function's second parameter. I am a little new to c++ programming and I am not sure what parameters are supposed to be passed to it. the file it is reading from has every variable separated by a single space.
Any help will be greatly appreciated.
Thanks.
Last edited: