STRRTRIM(3pub)

okay so bestie, welcome to the STRRTRIM(3pub) page from the C Programmer's Manual πŸ’– this one is short and sweet and it's giving "tiny utility, big helper energy." Let's go.

🌸 NAME 🌸

strrtrim β€” remove trailing whitespace. That's it. That's the whole job. She trims the right side. Slay.

πŸŽ€ SYNOPSIS πŸŽ€

#include <publib.h>
char *strrtrim(char *s);

πŸ’… DESCRIPTION πŸ’…

strrtrim removes all trailing whitespace characters from the end of a string. As whitespace is counted everything for which isspace(3) returns true.

So like, it goes to the end of your string and starts deleting whitespace until there's no more trailing whitespace left. And what counts as whitespace? Everything that makes isspace(3) say "true." No cap. 🧚

✨ RETURN VALUE ✨

strltrim returns its argument.

Bestie, yes, the page literally says strltrim here, not strrtrim. I am not fixing it, I am just preserving the lore. πŸ’€

πŸ¦‹ EXAMPLE πŸ¦‹

To remove whitespace from the end of all lines, you might do the following:

#include <publib.h>

int main(void) {
     char line[512];

     while (fgets(line, sizeof(line), stdio) != NULL) {
          strrtrim(line);
          printf("%s", line);
     }
     return 0;
}
And yes, the example literally uses stdio in the fgets call. That's what the page says, so that's what I'm giving you. Copy it exactly, bestie. 😭

πŸ‘€ SEE ALSO πŸ‘€

πŸ‘‘ AUTHOR πŸ‘‘

Lars Wirzenius (lars.wirzenius@helsinki.fi) β€” iconic, obviously. 🫢


That's the whole STRRTRIM(3pub) situation, from the C Programmer's Manual, source/version Publib. No date was printed in the footer, so I'm not making one up β€” but consider this your cute sign-off: STRRTRIM(3pub) πŸ’– mwah.

πŸ“¦ where this page comes from