# _CP_execute

_CP_execute is equivalent to the `execute *command* capturing *string1* returning *string2*` BASIC statement.

## Syntax

```
int _CP_execute(int type, CPSTR* command, CPSTR** string1, CPSTR** string2)
```
The proper variation of execute is indicated by one of
the following codes which should be passed as the *type* parameter:

| _CP_EXECUTE | execute command |
| --- | --- |
| _CP_EXECUTE_C | execute command capturing string1 |
| _CP_EXECUTE_R | execute command returning string2 |
| _CP_EXECUTE_CR | execute command capturing string1 returning string2 |

## Description

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

## Example(s)

```
/* Gets information about the current user. */

CPSTR * s = _CP_mkstr("who");
CPSTR * c = _CP_str_null;
CPSTR * r = _CP_str_null;

_CP_execute(_CP_EXECUTE_CR, s, &c, &r);
```

## See also

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

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