BREAKLINE(3) | Schily´s LIBRARY FUNCTIONS | BREAKLINE(3) |
NAME¶
breakline() - breaks a buffer into fields
SYNOPSIS¶
int breakline(buf, delim, array, max) char *buf; char delim; char *array[]; int max;
DESCRIPTION¶
breakline() breaks the buffer buf into fields delimited by the character delim, replacing the occurrences of delim in buf with the NULL character ('\0'). It fills in the array with pointers to the beginning of each field in the buffer. max defines how many entries to fill in the array. If there are not enough fields in buf, the extra entries in the array will point to an empty string.
RETURNS¶
Returns the number of fields actually in the buffer, but not more than max.
EXAMPLES¶
char *buf = "a:bc:d:efg"; char *array[10]; breakline(buf, ':', array, 10); now the `:' are replaced by '\0' and: array[0] = "a"; array[1] = "bc"; array[2] = "d" array[3] = "efg"; array[4] ... array[9] = "";
SEE ALSO¶
2022/09/09 | Joerg Schilling |