i try to do a reversed word program, and when i input the strrev(word) it doesn't work , it says "Implicit declaration of function 'strrev' is invalid in C99" & "Incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'" although i put #include <string.h> . what should i do ?
strrev is not a Standard C function and is not included in the libraries provided with Xcode.what should i do ?
You may need to define it by yourself.
how can i define it ? can you guide me with me that :) @OOPer
You can find many articles defining strrev, but it would be better for you to do it by yourself if you are learning C-programming.how can i define it ?
thanks for the help but after i defined it , i have another error which is " Incompatible pointer to integer conversion passing 'char [100]' to parameter of type 'char' " . do you have any idea what should i do ?
You should show your code.do you have any idea what should i do ?
here's my code :)
#include <stdio.h>
#include <string.h>
int main()
{
char word[100];
char words[100];
char strrev(char word);
printf("Input your word:");
gets(word);
strcpy(words,word);
printf("Reversed:");
printf("%c",strrev(words));
if((strcmp(word,words)==0))
printf("It is a palindrome word");
else
printf("It is not a palindrome word");
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char word[100];
char words[100];
char strrev(char word);
printf("Input your word:");
gets(word);
strcpy(words,word);
printf("Reversed:");
printf("%c",strrev(words));
if((strcmp(word,words)==0))
printf("It is a palindrome word");
else
printf("It is not a palindrome word");
return 0;
}
Thanks. It's a little bit far from I imagined...here's my code :)
It should be something like this:
Code Block #include <stdio.h> #include <string.h> char *strrev(char *word) { //... <- You need to implement `strrev` by yourself } int main(int argc, const char * argv[]) { char word[100]; char words[100]; printf("Input your word:"); gets(word); //<- `gets` is unsafe. Better not use it. strcpy(words,word); printf("Reversed:"); printf("%s\n", strrev(words)); if( strcmp(word,words) == 0 ) { printf("It is a palindrome word\n"); } else { printf("It is not a palindrome word\n"); } return 0;, }
If you want to practice C-programming with Xcode, you should better find a better textbook which is written for Standard C.