Implement AccessIgnoreCas e() to count the number of stations from the head to a destination using linked list.
for e.g.
PoLam->HangHau->TseungKwanO->TiuKengLeng->YauTong->QuarryBay->NorthPoint->NIL
Implement Access() which is case sensitive. However, it crashes when input does not match the string. How can I resolve this and how can I write a AccessIgnoreCas e() which is case insensitive?
int List::Access(st ring str)
{
if (m_Head == NULL)
return -1;
else
{
if (m_Head->str == str)
return 0;
else
{
int counter = 0;
Node* current;
current = m_Head;
while (current!= NULL)
{
counter++;
if (current->ptrNext->str == str)
return counter;
else
current = current->ptrNext;
}
if (current == NULL)
return counter;
}
return -1;
}
}
for e.g.
PoLam->HangHau->TseungKwanO->TiuKengLeng->YauTong->QuarryBay->NorthPoint->NIL
Implement Access() which is case sensitive. However, it crashes when input does not match the string. How can I resolve this and how can I write a AccessIgnoreCas e() which is case insensitive?
int List::Access(st ring str)
{
if (m_Head == NULL)
return -1;
else
{
if (m_Head->str == str)
return 0;
else
{
int counter = 0;
Node* current;
current = m_Head;
while (current!= NULL)
{
counter++;
if (current->ptrNext->str == str)
return counter;
else
current = current->ptrNext;
}
if (current == NULL)
return counter;
}
return -1;
}
}
Comment