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.

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.