>>for(i=0;i<=d-1;i++)
Why not just i < d to avoid subtracting 1 from d on every loop iteration.
And it might be better to use another counter intead of all those subtractions. Note also that you don't need the str2 variable.
int x;
x = strlen(str) - 1;
for(i = 0; flag == 0 && i < d; i++, x--)
{
if( str[i] != str[x] )
{
flag = 1;
}
}
Ancient Dragon
Achieved Level 70
32,269 posts since Aug 2005
Reputation Points: 5,852
Solved Threads: 2,590
Skill Endorsements: 70