Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
String Reverse Question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Richard Delorme, post: 1707249"] pete a écrit : The function receives a pointer to char. I also notice that the above function cannot portably deal with literal strings but contains a test to see if s is a null pointer. So the above code as to do with null pointer, but not necessarily with strings. I don't mean that a reversal function is supposed to work on any broken input, but I think the code should be consistent. The problem is that the 'if (s)' test comes after a call to strlen(), so it is useless, as strlen() exhibits undefined behaviour (e.g. on my implemetation, it crashes) when receiving a null pointer. So the 'if (s)' test is either misplaced or useless. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
String Reverse Question
Top