STRDEL(3pub)

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

okay bestie, welcome to the strdel page from the C Programmer's Manual (section 3pub, publib girlies rise) β€” it's giving "snip the front off a string" and honestly? iconic. βœ‚οΈβœ¨


🌸 NAME 🌸

strdel β€” delete characters from beginning of string πŸ¦‹


✨ SYNOPSIS ✨

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

πŸ’… DESCRIPTION πŸ’…

so basically, strdel removes the first n characters of s. that's it. that's the whole job. she's a simple queen. πŸ‘‘

and if n is bigger than the length of the string? no cap, it removes all the characters in the string β€” but like, not counting '\0' β€” and no more than that. it does not go off the end and start deleting random memory, she is way too classy for that. πŸ™ˆ


🫢 RETURN VALUE 🫢

strdel returns its first argument. just hands it right back to you. main character behavior, honestly. πŸ’–


πŸŽ€ EXAMPLE πŸŽ€

say you wanna change all occurrences of "Pascal" in the input to "Yuck!" β€” relatable, honestly β€” you might do the following:

#include <string.h>
#include <stdio.h>
#include <publib.h>

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

     while (fgets(line, sizeof(line), stdio) != NULL) {
          while ((p = strstr(line, "Pascal")) != NULL) {
               strdel(p, 6);
               strins(p, "Yuck!");
          }
          printf("%s", line);
     }
     return 0;
}

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Lars Wirzenius (lars.wirzenius@helsinki.fi) β€” the legend himself πŸ’œ


and that's the whole page, bestie!! this was Publib's C Programmer's Manual, STRDEL(3pub) β€” go forth and delete those leading characters fr fr πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from