Next: , Previous: , Up: Top   [Contents][Index]


7 Using the Strings utility

The strings utility defines some handy functions for dealing with strings. Strings in C are problematic: they involve a lot of pointer manipulation which is often complicated, error-prone and a source of bugs. The strings utility defines a wrapper type for strings (only for convenience), which is defined as:

typedef char *str;

The functions of the strings utility, as defined in "strings.h", are:

int indexof(str string, char chr);
int nindexof(char chr);
int lindexof(str string, char chr);

str substr(str string, int start);
str nsubstr(str string, int start, int length);
str ltrim(str string);
str rtrim(str string);
str trim(str string);

str toupper(str string);
str tolower(str string);

What the functions do is as following:


Next: , Previous: , Up: Top   [Contents][Index]