1,105,546 Community Members

strrev function.

Member Avatar
osei-akoto
Newbie Poster
12 posts since Jul 2009
Reputation Points: -1 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
dkalita
Posting Pro in Training
402 posts since Sep 2009
Reputation Points: 110 [?]
Q&As Helped to Solve: 61 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
yellowSnow
Posting Whiz in Training
203 posts since Jul 2009
Reputation Points: 607 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 2 [?]
 
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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article