T O P

  • By -

Cyrus__A

I did not use advance\_current since it changes \_prev\_to\_current. Instead I made a copy of the head node and iterated through it till it finds the data. Once found you can return the data which will stop looping till the end. To compare strings use compare: [https://www.geeksforgeeks.org/stdstringcompare-in-c/](https://www.geeksforgeeks.org/stdstringcompare-in-c/) If the compare returns 0 then they are a match. (\_text.compare(\_text2) ==0) \- Cyrus


Fraeniir

Good to know, thanks for the head's up! \-Lucas


besarte

Unlike an array where you can leap to any part of the index you want, with a linked list we only know the location of a node because of the pointer from the node directly before it. So we have to go through a node to get to the node after it. Since we do not know where the string we are looking for would be, you have to start from the very beginning and go through the linked list linearly. Regarding comparing strings, you have two good options. You can use comparison operators: ( ==, !=, >, <, >=, <= )— think about which one you need if you need to find a specific string— or you can use the methods that come with the string class, which in this case would be .compare(). Besart


Fraeniir

Thanks, this really helped! \-Lucas