GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
getfields(l) BEGEMOT Library getfields(l)

getfields, getmfields, setfields - split string into fields

# include <begemot.h>

int getfields(char *str, char **fields, int nfields);

int getmfields(char *str, char **fields, int nfields);

char *setfields(char *delim);

getfields and getmfields split the input string in substrings as defined by a set of delimiting characters. The pointer array fields is filled with pointers to the starts of the substrings. Each substring is terminated with a NUL character (the original string is modified). The number of entries in the array is given with nfields. If the string contains more substrings than nfields specifies, the last pointer in fields will point to the rest of the string. If there are lesser substrings than entries in fields, the substring pointer array will be NULL terminated. Both functions return the number of substrings found.

getfields and getmfields differ in the interpretation of multiple delimiting characters. getfields interprets two consecutive delimiters as an empty field, whereas getmfields collapses multiple delimiters.

setfields sets a new set of delimiters. A string containing the old delimiting characters is returned. The default set is "\t ". The NUL character is always interpreted as a delimiter and end of string.

getfields and getmfields return the number of substrings. setfields returns a pointer to static memory containing the old delimiting characters. This is valid only until the next call to setfields and can directly be feed into the next setfields call.

strtok(3),

Could, perhaps, be more performant.
12 Sep 1996 BEGEMOT

Search for    or go to Top of page |  Section l |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.