STRZAP(3pub)
β¨ STRZAP(3pub) β¨
okay so bestie, welcome to the strzap page from the C Programmer's Manual π this one's a lil function from publib and she is tiny but she is mighty, fr fr.
πΈ NAME πΈ
strzap β remove pattern from beginning of string, if it is there π
like. if the pattern is there, she zaps it. if it's not there, she does nothing. no drama, no notes. π
π¦ SYNOPSIS π¦
#include <publib.h>
int strzap(char *str, const char *pat);
that's it. that's the whole vibe. one header, one function, two args. iconic. β¨
π DESCRIPTION π
so here's the tea β strzap compares the beginning of str with all of pat, and if they are the same, it removes the beginning from str.
the way that it literally just looks at the front of your string and checks "hey, is this the pattern?" β and if yes? gone. removed. no cap. the beginning of str gets yeeted and what's left is what comes after the pattern. π«Ά
if they're not the same, she simply does not touch anything. main character energy: unbothered, moisturized, in her lane. π
π₯ RETURN VALUE π₯
strzapreturns non-zero if it removed anything- returns
0if not
so like, check the return value if you wanna know whether the zap actually happened. it's giving "receipts". π§
π SEE ALSO π
(yes bestie, there's a sibling function that zaps from the end. go look at strendzap(3) if that's your thing. iykyk π)
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β thank you for this lil gem, king π
β οΈ reminder bestie:strzapmodifiesstrin place when it zaps, so don't be passing in anything you can't/shouldn't change. the manpage doesn't say more than that, so i'm not gonna make stuff up. periodt. π
and that's the whole page, fr fr π this was Publib, from the C Programmer's Manual β STRZAP(3pub), mwah, slay, go zap some strings bestie π
β¨π
π¦ 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