- #1
Kontilera
- 179
- 23
Homework Statement
Make a code that can check if one or many words are palindromes.
The Attempt at a Solution
I can't get my compiler to work so I wrote my attempt in a note document. Please can you check if it works and if it doesn't give me some guidence.. I have put a lot of time into the problem and now I thought I was finished but my computer stops working.
I suspect that I have missused strtok() but "," should separate the words.
Thanks.
PHP:
#include <stdio.h>
#include <string.h>
main()
{
i=1;
char words[100], invers[100], word[50];
printf("Please write your words:\n");
gets(words);
word= strtok(words, ,);
while(word != NULL){
strcpy(invers,word);
strrev(invers);
if( strcmp(word,invers) == 0 )
printf("%s - Palindrome!\n", ord );
else
printf("%s Not Palindrome!\n", ord );}
return 0;