STRRIGHT(3pub)

πŸ’– STRRIGHT(3pub) πŸ’–

okay bestie, welcome to the C Programmer's Manual ✨ this is a page from publib, and today we're talking about strright β€” she's a tiny little string helper and honestly? she's giving ✨effortless✨


🌸 NAME 🌸

strright β€” return a pointer to the beginning of the rightmost n chars in a string πŸŽ€


✨ SYNOPSIS ✨

#include <publib.h>
char *strright(const char *s, size_t n);

like, that's it. two lines. she's low maintenance πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so strright hands you back a pointer to the first of the n rightmost characters in the string s β€” and no, bestie, the '\0' does not count, she's not invited to that party πŸ™ˆ

and here's the part that makes her kind of iconic: she does not make a copy of the string. not even a little one. she just returns a pointer into the argument string. same memory, same vibes, zero duplication πŸ’–

so like, if s changes, your pointer is pointing at the live thing, not a snapshot. no cap. that's the whole function. short queen πŸ‘‘


🌈 SEE ALSO 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Lars Wirzenius</purl> β€” wait no, Lars Wirzenius (lars.wirzenius@helsinki.fi) wrote this one and we thank him for his service πŸŽ€βœ¨


πŸ’€ reminder bestie: this is publib, so if you're out here expecting this exact function in glibc, check yourself before you wreck yourself. iykyk.

and that's the page!! this one shipped as part of Publib, in the C Programmer's Manual, filed under STRRIGHT(3pub) β€” mwah, go forth and point at the right side of your strings responsibly πŸŒΈπŸ’…πŸ¦‹

πŸ“¦ where this page comes from