STRREV(3pub)
π STRREV(3pub) π
okay bestie, welcome to the C Programmer's Manual, section 3pub β this is the publib corner of the library, and today's main character is a little function called strrev β¨
πΈ NAME πΈ
strrev β flips a string around, right there in place, no copy, no drama π
π¦ SYNOPSIS π¦
#include <publib.h>
char *strrev(char *str);
β¨ DESCRIPTION β¨
so strrev reverses the string you hand it, and it does it in place β meaning it literally swaps the *i*th character counting from the front with the *i*th character counting from the back. no new buffer, no sneaky allocation, just vibes and swaps π«Ά
π RETURN VALUE π
strrev returns its argument. that's it, that's the whole return. it gives you back the same pointer you gave it, but now the string is backwards π iconic behaviour honestly
π EXAMPLE π
say you wanted to reverse "dlrow, elloh" β you'd do it like this:
char str[] = "dlrow, elloh";
puts(strrev(str));
and this would output "hello, world" π
β οΈ heads up bestie: using a string literal as the argument would be an error, because it is not allowable to modify string literals. like, do not do that. she will not survive it π
π BUGS π
okay so the tea: strrev does not automatically detect palindromes, and it also does not automatically return without doing anything. so if you were hoping for a lil self-aware function that goes "omg this is already the same backwards, I'll just chill" β nope. she does not do that. not in her skill set π
π₯ SEE ALSO π₯
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi)
and that's the whole page, bestie!! π this was STRREV(3pub) from the Publib collection, chillin' in the C Programmer's Manual β mwah, go reverse something responsibly, ily πβ¨π¦
π¦ where this page comes from
- debian bookworm: publib-dev 0.40-3+b1 Β· BSD-2-Clause
- debian trixie: publib-dev 0.40-4 Β· BSD-2-Clause
- ubuntu jammy: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu noble: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu questing: publib-dev 0.40-4
- ubuntu resolute: publib-dev 0.40-4build1 Β· BSD-2-Clause
- ubuntu stonking: publib-dev 0.40-4build1 Β· BSD-2-Clause
- Copyright (c) 1994-2006 Lars Wirzenius. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms