STRENDZAP(3pub)

✨ STRENDZAP ✨

okay bestie, welcome to the strendzap page from the C Programmer's Manual β€” she's a publib girlie and she's about to end your suffix problems. πŸ’…


🌸 NAME 🌸

strendzap β€” remove a pattern from the end of a str, if it's even there πŸ‘€


πŸŽ€ SYNOPSIS πŸŽ€

#include <publib.h>
int strendzap(char *str, const char *pat);

πŸ’– DESCRIPTION πŸ’–

so here's the tea, bestie: strendzap looks at the end of str, and if pat is chillin' right there at the end, it removes it. iconic behaviour. πŸ¦‹

if pat is not at the end of str? she simply does nothing. no drama, no notes, just vibes. ✨


πŸ”₯ RETURN VALUE πŸ”₯

  • non-zero β†’ she actually removed something, slay πŸ’…
  • 0 β†’ nothing was removed, it's giving nothing happened 🫢

🌈 EXAMPLE 🌈

say you wanna remove the suffix .c from the end of a filename (classic move), you'd do this:

#include <publib.h>

strendzap(filename, ".c");

periodt. πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘


🧚 AUTHOR 🧚

Lars Wirzenius (lars.wirzenius@helsinki.fi) β€” the main character who brought us this ✨


this has been a Publib moment, brought to you by the C Programmer's Manual β€” stay zapping, bestie, ily πŸŒΈπŸ’œ

πŸ“¦ where this page comes from