when I implement the function
char *strchr( const char *string, int c );
I got a problem. If I wrote like this:
char *my_strchr(const char *string, int c)
{
while(*string && *string!=c){
string++;
}
return string;
}
I was told the string is const char*, and the return value is char*, can not return directly.
If I use new a char pointer, I also can not use assign operator directly since char * = const char* is wrong. What should I do in this situation?
Thanks.
char *strchr( const char *string, int c );
I got a problem. If I wrote like this:
char *my_strchr(const char *string, int c)
{
while(*string && *string!=c){
string++;
}
return string;
}
I was told the string is const char*, and the return value is char*, can not return directly.
If I use new a char pointer, I also can not use assign operator directly since char * = const char* is wrong. What should I do in this situation?
Thanks.