# _CP_substr

_CP_substr is equivalent to the `*result* = string[*beg.pos.expression*, *len.expressio*n]` BASIC statement.

## Syntax

```
int _CP_substr(CPSTR** result, CPSTR* string, int beg.pos.expression,
int len.expression)
```

## Description

This function returns -1 if
an error occurs. The error code is contained in _CP_errno.

## Example(s)

```
/* Prints "h". */

CPSTR * s = _CP_mkstr("hi");

_CP_substr(&s,s,1,1);
_CP_print(s);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)

---
Source: https://d3codex.com/cfunctions/cp-substr/ - part of the D3Codex reference.
