Ive searched the board and seen the other palindrome examples but its too complex for me. Ive implemented my own but i have an error which bugs me.
C:\src\palindromes\palindromes.c(117) : warning C4133: 'function' : incompatible types - from 'int [1000]' to 'const char *'
something wrong with my remblanks, but ive done the same operation in most of the other functions, i dont see why its happening here.
Anyone see whats wrong with my code?
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define SIZE 1000
void get_sentence( char [] );
int is_palindromes( char [] );
void lower( char [] );
void reverse( char [] );
void remblanks( char [] );
int main()
{
char words[SIZE];
get_sentence(words);
if (is_palindromes(words))
{
printf( "%s is a palindrome!\n", words );
} else {
printf( "%s is NOT a palindrom!\n", words );
}
return 0;
}
void get_sentence( char words[] )
{
int ch;
int n=0;
printf( "Enter your sentence:\n" );
while ( (ch=getchar()) != '\n' ) {
words[n] = ch;
n++;
}
words[n] = '\0'; /* insert null at end of string */
}
int is_palindrome( char words[] )
{
char x[SIZE], temp[SIZE];
int i, n=0, palin;
strcpy( x, words );
strcpy( temp, words );
reverse ( x );
lower( x );
lower( temp );
remblanks( x );
remblanks( temp );
for ( i=0; i<n; i++ ) {
if ( x[i] == temp[i] ) {
palin=1;
}
else {
palin=0;
break;
}
}
return palin;
}
void lower( char words[] )
{
int i, n=0, size;
char temp[SIZE];
size = strlen(words);
for (i=0; i < size; i++) {
if ( islower( words[i] ) ) {
temp[n] = words[i];
n++;
}
else {
temp[n] = words[i];
n++;
}
}
strcpy( words, temp );
}
void reverse( char x[] )
{
char copyarray[SIZE];
int i, n=0;
for (i=strlen(x); i>=0; i--) {
copyarray[n] = x[i];
n++;
}
strcpy( x, copyarray );
}
void remblanks( char words[] )
{
int temp[SIZE];
int i, n=0, size;
size = strlen(words);
for ( i=0; i < size; i++ ) {
if ( words[i] != ' ' ) {
temp[n] = words[i];
n++;
}
}
strcpy( words, temp );
}