Blast-Radius Aware AI Code Review for Business-Critical Systems
LiveReview LiveReview Explore LiveReview

strdel - delete characters from beginning of string

Author

       Lars Wirzenius (lars.wirzenius@helsinki.fi)

Publib                                        C Programmer's Manual                                 STRDEL(3pub)

Description

strdel  removes  the  first  n  characters  of  s.   If  n  is greater than the length of the string, all
       characters in the string (not counting '\0') are removed but no more.

Example

       To change all occurrences of "Pascal" in the input to "Yuck!", 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;
            }

Name

       strdel - delete characters from beginning of string

Return Value

strdel returns its first argument.

See Also

publib(3), strins(3)

Synopsis

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

See Also