0

Please can somebody explain to me whether sometimes the strrev function fails or not.
I was giving an assignment to write an application that can detect whether an entered word from the keyboard is a palindrome or not.
After accepting the string and tried to use the function from the string.h.

3
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by yellowSnow
0

Please can somebody explain to me whether sometimes the strrev function fails or not.
I was giving an assignment to write an application that can detect whether an entered word from the keyboard is a palindrome or not.
After accepting the string and tried to use the function from the string.h.

1> i have never seen strrev() in string.h. May be it is there in some compiler other than i have used.

2> if its there there and is a library function then there is seldom chance that it will fail. Try to get its manual and read.
It would be better if u recheck your code or write your own strrev() which servs your purpose.

Edited by dkalita: n/a

0

Please can somebody explain to me whether sometimes the strrev function fails or not.
I was giving an assignment to write an application that can detect whether an entered word from the keyboard is a palindrome or not.
After accepting the string and tried to use the function from the string.h.

You don't necessarily need a "string reverse" function to check for palindromes.

For a string of length N, how about:
1. check if the 1st and Nth character are equal, if so, then:
2. check if the 2nd and (N-1)th character are equal, if so, then:
3. check if the 3rd and (N-2)th character are equal,
.......etc etc.

If any of the conditions fail, then you don't have a palindrome.
This can be done iteratively or recursively.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.