Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > B

bufsplit(3G)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

bufsplit() — split buffer into fields

SYNOPSIS

#include <libgen.h>

size_t bufsplit(char *buf, size_t n, char **a);

DESCRIPTION

bufsplit examines the buffer, buf, and assigns values to the pointer array, a, so that the pointers point to the first n fields in buf that are delimited by tabs or new-lines.

To change the characters used to separate fields, call bufsplit with buf pointing to the string of characters, and n and a set to zero. For example, to use ':', '.', and ',' as separators along with tab and new-line:

bufsplit(":.,\t\n", 0, (char**)0);

To use this interface, link in the libgen library by specifying -lgen. For example:

cc foo.c -lgen

RETURN VALUE

The number of fields assigned in the array a. If buf is zero, the return value is zero and the array is unchanged. Otherwise the value is at least one. The remainder of the elements in the array are assigned the address of the null byte at the end of the buffer.

EXAMPLES

/* * set a[0] = "This", a[1] = "is", a[2] = "a", * a[3] = "test" */ bufsplit("This\tis\ta\ttest\n", 4, a);

WARNINGS

bufsplit changes the delimiters to null bytes in buf.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.