idx_in_list()

idx_in_list()#

The function idx_in_list() searches for a string in a list of strings and returns its index if found, or -1 if not found.

Prototype

int idx_in_list(
    const char **list,
    const char *str,
    BOOL ignore_case
);

Parameters

Key

Type

Description

list

const char **

A null-terminated array of string pointers to search within.

str

const char *

The string to search for in the list.

ignore_case

BOOL

If TRUE, the comparison is case-insensitive; otherwise, it is case-sensitive.


Return Value

Returns the index of str in list if found, or -1 if not found.

Notes

The function iterates through the list and compares each element with str using either strcmp() or strcasecmp() based on the ignore_case flag.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples