bachra04
asked on
'const char *' to 'char *'
Hi Experts,
char* pszFind = strstr(CStr()+uStartIndex, pSzSearch);
I got the following error :
cannot convert from 'const char *' to 'char *'
I need help tp resolve this problem ?
Thanks,
char* pszFind = strstr(CStr()+uStartIndex,
I got the following error :
cannot convert from 'const char *' to 'char *'
I need help tp resolve this problem ?
Thanks,
I don't knw which of the parameters the compiler complains about (since all input parameters to 'strstr()' usually are 'const char*'), but maybe a 'const_cast<char*>()' can help, see http://www.cprogramming.com/reference/typecasting/constcast.html
I don't think the problem is with what strstr is expecting, I think the issue is just with the part...
What are you trying to achieve with this? It doesn't really make sense.
CStr()+uStartIndex
What are you trying to achieve with this? It doesn't really make sense.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi infinity08,
Yes it compiles like you suggested, I just have one question is :
this is the rest of the code , is that safe to convert it to const char* :
if (pszFind != NULL)
{
uIndex = pszFind - CStr();
}
Yes it compiles like you suggested, I just have one question is :
this is the rest of the code , is that safe to convert it to const char* :
if (pszFind != NULL)
{
uIndex = pszFind - CStr();
}
If uIndex is a const char*, that should be ok, yes.