I'm trying to compare the string in my linked list to a string in a new node so i can compare them alphabetically. My compiler expected a primary expression before '->'. How can i use the values in my linked list as variables and compare strings?
struct element {
std::string woord;
struct element * next = NULL;
};
void VoegToeAlfabetisch(element** lijst, std::string tekst)
{
element* x(new element);
x->woord = tekst;
while (*lijst != NULL) {
std::string print = element->woord;
}
}
int main()
{
element* root = NULL;
VoegToeAlfabetisch(&root, "Alfabetisch");
return 0;
}
maybe you mean
element is the name of a type not a variable. This code has an infinite loop in it, but I assume you will fix that once you get it to compile
Also, please post the exact error message and comment the line it points to in any question you post with compiler errors.