Cannot convert const char * to char *

Posted by robUK on Stack Overflow See other posts from Stack Overflow or by robUK
Published on 2010-03-09T09:42:15Z Indexed on 2010/03/09 9:51 UTC
Read the original article Hit count: 399

Filed under:
|

Hello,

Visual Studio c++ 2005

I am getting an error on the last line of this code.

int Utils::GetLengthDiff ( const char * input, int & num_subst ) 
{
    int num_wide = 0, diff = 0 ; 
    const char * start_ptr = input ; 

    num_subst = 0 ; 
    while ( ( start_ptr = strstr ( start_ptr, enc_start ) ) != NULL ) 
    {
        char * end_ptr = strstr ( start_ptr, enc_end ); // Error

So I changed the line to this and it worked ok

const char * end_ptr = strstr ( start_ptr, enc_end ); 

So why would I need to declare end_ptr as a const as well?

Many thanks,

© Stack Overflow or respective owner

Related posts about visual-studio-2005

Related posts about c++