I have part of my code that i do not know how to solve the error. my input in the file is something like.
age, (4, years, 5, months)
age, (8, years, 7, months)
age, (4, years, 5, months)
1 2 3 4 5 6 7 8 9 10 11
char * point
ifstream file;
file.open(file.c_str());
if(file.is_open())
{
while(file.good())
{
(getline(file, take));
point =strtok(take,", ()");
}
}
im trying to remove all the delimiters and that is bothering me very much. How can i convert take into char * to solve the error which reads cannot convert"std::string to char*"? i have tried changing my take into take.c_str() but its still the same.
strtok works with character arrays. You may not pass an object of type std::string to the function. Also strtok changes the original character array. So you may not use neither take.c_str() nor take.data().
I would suggest to use std::istringstream( take ) instead of strtok.
Thanks alot for your suggestion. i will start reading on how to implement that. I'm currently still trying to split the data input. when i tried running the code the 1st line was ok. But subsequent line has age missing.