LinkedList::LinkedList(const value_type& input)
{
value_type delim = " ";
int start = 0;
size_t pos = 0;
value_type nWord;
value_type tString = input;
while ((pos = tString.find(delim)) != value_type::npos) {
nWord = tString.substr(0, pos);
std::cout << nWord << std::endl;
tString.erase(0, pos + 1);
}
std::cout << tString << std::endl;
}
LinkedList firstSen("i am testing A linked list");
LinkedList secSen("again i am testing");
i am trying to print out a sentence into words before i add them to nodes in my linked list (to test if its working). when i create the linked lists firstsen and secsen in my main function i am getting the output of all the words separated by new lines (which is what i want) but at the end it says "Segmentation fault (core dumped)".
I think this means im reading memory i dont have access to but i cant figure out what is causing that.