i've been trying to make this function work... but to no avail :(
pal (int *str)
if (*(str+i) != x[i])
Can anyone help me plz :confused:
Here's an easy way:
You could of course optimize this to use only half the length, but that's the easiest way. Of course, this doesn't count or allow for white space, and it doesn't check case sensitivity.
for( x = 0, y-1 = strlen( foo ); x < strlen( foo ); x++,y-- )
if( foo[x]!=foo[y] )
printf( "Not a palindrome." );
You have declared str as int *
This could be ok, but then you would have to cast it to char
before comparing with '\0'
easiest would be to change int *str to char *str