int isPurePalindrome(const char *sentence){
int i;
if (sentence="")
return 0;
char *begin; char *end; i=strlen(sentence);//i is now the length of sentence string
*begin= &sentence(0);
*end=&sentence[i-1];
I'm using dev c++. Im trying to initialize pointer "begin" to point to the first character in the string "sentence", but it keeps giving me an error that "assignment makes integer from pointer without a cast." "*sentence" points to the string entered by the user in the main. ispalindrome is a function im writing. its suppose to return a 0 if the sentence entered in main is a NULL.
There are a few issues with your 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];
There are a bunch of problems in your code, but the one causing that error message is that you're dereferencing when you don't need to be. You want:
begin = &sentence[0];
end = &sentence[i-1];
begin = &sentence[0];
end = &sentence[i - 1];
This will solve your problem..
You should write []
insted of ()
in
*begin= &sentence(0);
you should caste sentence to (char*) before assigning it to begin and end.
*begin = ((char*)sentence)[0];
*end = ((char*)sentence)[i -1];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.