BREAKLINE(3)
πΈ BREAKLINE(3) β SchilyΒ΄s LIBRARY FUNCTIONS πΈ
okay bestie, welcome to the breakline page π this one lives in SchilyΒ΄s LIBRARY FUNCTIONS and it's honestly such a vibe once you get it.
β¨ NAME β¨
breakline() β breaks a buffer into fields π
π¦ SYNOPSIS π¦
int breakline(buf, delim, array, max)
char *buf;
char delim;
char *array[];
int max;
π DESCRIPTION π
so here's the tea β: breakline() takes the buffer buf and chops it into fields, with the character delim doing the dividing βοΈ and while it's at it, it replaces every occurrence of delim inside buf with the NULL character ('\0') β lowkey destructive but in a cute way π«Ά.
Then it fills in array with pointers to the beginning of each field in the buffer. max says how many entries you get to fill in that array, no more, no cap π§’.
and if buf doesn't have enough fields to go around? the extra entries in array just point to an empty string. everyone gets a seat bestie, even the empties πβ¨
π RETURNS π
returns the number of fields actually in the buffer β but never more than max, obviously. periodt π
π EXAMPLES π
okay icon, say you've got this:
char *buf = "a:bc:d:efg";
char *array[10];
breakline(buf, ':', array, 10);
now the : are replaced by '\0' and boom π₯:
array[0] = "a";
array[1] = "bc";
array[2] = "d"
array[3] = "efg";
array[4] ... array[9] = "";
look at that. iconic behaviour honestly π§π
π SEE ALSO π
bestie reminder: this page is from SchilyΒ΄s LIBRARY FUNCTIONS, written by Joerg Schilling, dated 2022/09/09 β go off and break some lines responsibly π slay β¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: libschily-devel-doc 2022.10.16-160000.2.2 Β· CDDL-1.0
- Copyright 1988,2020 J. Schilling
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms