Hi,
i have started writing a program for palindrome checking of characters.
i have written the following program
Code:
#include <stdio.h>
int check(char *data,int len);
int main(int argc, char **argv)
{
char array[100];
int len=0;
printf("Enter the string less than 100 chars\n");
scanf("%s",array);
len = strlen(array);
check(array,len);
return 0;
}
int check(char *data, int len)
{
char array[100];
int index=0;
data += len;
while(len--)
array[index++] = *data--;
printf("%s%d",array,len);
return 1;
}
i have not completed the program. But i tried to run the program i found that the len variable is -1. How the len variable is -1 it should have been the length of the string. why am i getting -1? Can someone please help me.
Thanks and regards,
satya