STRLTRIM(3pub)
π STRLTRIM(3pub) π
okay bestie, so this is a page from the C Programmer's Manual (the publib one, you know the vibes), and it's all about strltrim β the little function that yeets whitespace off the front of your string. she's simple, she's reliable, she's lowkey iconic. let's get into it π«Ά
β¨ NAME β¨
strltrim β remove leading whitespace from a string
like... that's her whole job. that's the assignment. and she ate. π
πΈ SYNOPSIS πΈ
#include <publib.h>
char *strltrim(char *s);
π¦ DESCRIPTION π¦
so here's the tea: strltrim removes all leading whitespace characters from the beginning of a string. how does she do it? not me asking the real questions β she does it by moving everything starting from the first non-whitespace character all the way to the beginning of the string. like, packing up and relocating to the front. main character energy fr fr. π
and what counts as "whitespace"? literally everything for which isspace(3) returns true. that's the vibe check. if isspace(3) says yes, it's whitespace, and it's getting trimmed. periodt.
π RETURN VALUE π
strltrim returns its argument. yes, the same pointer you handed her. she gives it right back. no cap. π
β EXAMPLE β
okay so say you wanna remove all the indentation from all the lines in a program β here's how you'd do it:
#include <publib.h>
int main(void) {
char line[512];
while (fgets(line, sizeof(line), stdio) != NULL) {
strltrim(line);
printf("%s", line);
}
return 0;
}
she reads a line, trims the front, prints it. over and over. it's giving dedicated. π₯
π SEE ALSO π
(the whole trim squad π«Ά β strrtrim does the back end, strtrim does both, and isspace is the one deciding what even counts.)
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β thank you king, we appreciate you π
and that's the whole page bestie! no missing details, no skipped sections, every single thing preserved. iykyk πβ¨
this iconic lil manual page is brought to you by Publib, dated as part of the C Programmer's Manual, filed under STRLTRIM(3pub). mwah π stay trimmed, stay slaying π¦πΈπ
π¦ 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