substr
Summary
#include <dataman/dataman.h>
-or-
#include <dataman/sort.h>
pt = substr(str,off1,off2);
char *pt, *str;
int off1,off2;
Description
This procedure returns a pointer to newly allocated space
that contains a substring of the passed argument. The
first argument is the source of the substring. The two
offsets are the beginning and ending offset, inclusive,
of the substring. The first offset must be less than or
equal to the second. The offsets are relative to zero.
The user is responsible for freeing the memory allocated
by substr. If the memory can not be allocated, or the
second offset is less than the first, the value NULL is
returned.
Example
#include <dataman/sort.h>
main(int argc, char *argv[])
{
char *pt;
...
pt = substr("hello world",6,10);
...
free(pt);
}
This call returns the string "world" in pt
«previous next»