Skip to content

Update 01.04.md#421

Open
Renzhh wants to merge 1 commit intojulycoding:masterfrom
Renzhh:patch-2
Open

Update 01.04.md#421
Renzhh wants to merge 1 commit intojulycoding:masterfrom
Renzhh:patch-2

Conversation

@Renzhh
Copy link
Copy Markdown

@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