navaneethan
September 15th, 2010, 12:03 PM
Consider this code,why we have to decrement the length by 2? for example
void strPass(char *str,int len) //(start addr,4)
{
if(str[0]==str[(len)-1]) //1st char comparision
strPass(str+1,len-2); //here why we are decrementing the length by 2
else
printf("This is not polin...");
}
main()
{
// Get the input string /*consider INPUT STRING=JAVA/0*/
len=strlen(str)-1; //4 is calculated
strPass(&str,len); //(start addr, 4) passed
}
void strPass(char *str,int len) //(start addr,4)
{
if(str[0]==str[(len)-1]) //1st char comparision
strPass(str+1,len-2); //here why we are decrementing the length by 2
else
printf("This is not polin...");
}
main()
{
// Get the input string /*consider INPUT STRING=JAVA/0*/
len=strlen(str)-1; //4 is calculated
strPass(&str,len); //(start addr, 4) passed
}