c++ - Initializing a pointer to point to a character in a string using the pointer pointing to the string -
int ispurepalindrome(const char *sentence){ int i; if (sentence="") return 0; char *begin; char *end; i=strlen(sentence);//i length of sentence string *begin= &sentence(0); *end=&sentence[i-1];
i'm using dev c++. im trying initialize pointer "begin" point first character in string "sentence", keeps giving me error "assignment makes integer pointer without cast." "*sentence" points string entered user in main. ispalindrome function im writing. suppose return 0 if sentence entered in main null.
there few issues code:
if (sentence="") return 0;
should be
if (strcmp(sentence,"")==0) return 0;
char *begin; char *end;
should be
const char *begin; const char *end;
*begin= &sentence(0);
should be
begin = &sentence[0];
*end=&sentence[i-1];
should be
end = &sentence[i-1];
Comments
Post a Comment