What is wrong with this program ?
hi,
after i ran this program it shows nothing, i have to use control + c to quit. I use debugger and it generate errors. How come, Pls tell me why thnx a lot.
Code:
#include <stdio.h>
int palindrome( char string[] );
int main()
{
char string[ 5 ] = "elle";
if ( palindrome( string ) == 1 )
printf( "It IS a palindrome." );
getch();
return 0;
}
int palindrome( char string[] )
{
int i = 0, length = 0;
while ( string[ i ] != '\0' )
++length;
if ( length - 1 == 1 || length - 1 == 0 )
return 1;
else if ( string[ 0 ] != string[ length - 2 ] )
return 0;
else {
string[ length - 2 ] = '\0';
return palindrome( &string[ 1 ] );
}
}