-2
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char frase[200], vetor_frase[200], palindromo[200];
int j = strlen(frase), x = 0, p =0;
printf("Digite uma frase:");
gets(frase);
for(int i = 0; i< j; i++)
{
if(frase[i] != ' ')
{
vetor_frase[x] = tolower(frase[i]);
x++;
}
}
for(int i= strlen(vetor_frase)-1; i>=0; i-- )
{
palindromo[p] = vetor_frase[i];
p++;
}
int comparacao = strcmp(vetor_frase, palindromo);
if (comparacao == 0)
{
printf(">A frase %s \n E UM PALINDROMO:%s",vetor_frase, palindromo);
}
else
{
printf("A frase %s \nNAO E PALINDROMO:%s",vetor_frase, palindromo);
}
return 0;
}
In C a string is an array of characters with the terminator ' 0'. You have not typed this terminator at the end of the sentence vector mount. Idem for palindromo.
– anonimo
That’s right brother. vlw!.
– Wellington Felix