Close
dtSearch Text Retrieval Engine Programmer's Reference
Null-delimited string set

A null-delimited string set is a way to pass a series of any number of strings as a single string pointer.

A null-delimited string set is a way to pass a series of any number of strings as a single string pointer. Each string has a terminating '\0' character, and a double '\0' indicates the end of the string. For example, the set "apple," "pear", "grape" would be represented as follows:

'a', 'p', 'p', 'l', 'e', '\0', 'p', 'e', 'a', 'r', '\0', 'g', 'r', 'a', 'p', 'e', '\0', '\0'

It is critical that the terminating double-null be included, because it is the only way to find the end of the list of strings. Without it, the program will try to find another valid string after the end of the data provided, which can result in a crash. Example:

dtsIndexJob job; // No terminating double-null, so this will case intermittent crashes job.toAdd.includeFilters = "*.c";

In C or C++, a single-null is automatically added at the end of string values. To add a double-null, it must be explicitly provided, like this:

dtsIndexJob job; job.toAdd.includeFilters = "*.c\0\0";