Skip to content

Conversation

@Renzhh
Copy link

@Renzhh Renzhh commented Jun 10, 2015

In the previous code, due to using s[first] and s[second], the program will be crashed with the error "Array subscript is not an integer". Both of "first" and "second" are a pointer to a char.

Code in details:

  1. The previous one:
while (first >= s)
    if (s[first--] != s[second++]) 
        return false; // not equal, so it's not apalindrome  

2.After changes:

while (first >= s)
{
    if(*first != *second)
        return false;
    first--;
    second++;
}

In the previous code, due to using s[first] and s[second], the program will be crashed with the error "Array subscript is not an integer". Both of "first" and "second" are a pointer to a char.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant