Stuck, Linked List find function.

Assignment due tomorrow. So this is what I am trying to get in my linked list project. I am stuck on the find function. I need help. The find is a integer. Basically the description with the string is apple, substring is ple, when you stumble to ple when comparing return the integer it first gets to, which is 2.

EXAMPLE if what I am trying to get to .
app == ple (0) false walk down the list
ppl == ple (1) false walk down the list
ple== ple (2) true return 2.


return (2)
The struct is provided, Im just stuck with the find function, I tried a few codes but got nothing. How should I go about it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
struct Node
{
	char acid;
	Node * next;
	

	Node(char letter)
	{
		acid = letter;
		next = nullptr;
	}
};


  int find(const DNA & subStr) const 
 // returns the first position subStr in self exists or -1
	{
		//   strand -> [ a | ] -> [ p|  ] -> [ p|   ] ->  [ l  ]-> [ e|   ] 
		// substr.strand ->[ p | ] -> [l|  ] -> [ e|   ]  
		// return 2




		Node * ptr = strand;
		Node * subStrPtr = subStr.strand;

		for (int i = 0; i < length; i++)
			if (ptr->acid != subStrPtr->acid)
				ptr = ptr->next;
			else
			{

			} the code you need help with here.
Registered users can post here. Sign in or register to post.