# _CP_writet

_CP_writet is equivalent to the writet BASIC statement.

| Type | BASIC Statement |
| --- | --- |
| _CP_WRITET_ELSE | writet string else return -1 |
| _CP_WRITET_ONERR | writet string onerr return -1 |
| _CP_WRITET_L_ELSE | writetl string onerr return -1 |
| _CP_WRITET_L_ONERR | writetl string onerr return -1 |

## Syntax

```
int _CP_writet(int type, CPSTR* string)
```

## Description

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

Note: The tape *must* have been already attached.

## Example(s)

```
/* Writes the next tape block. */
CPSTR * xx = _CP_mkstrl("data",4);
_CP_writet(_CP_WRITET_ELSE, xx);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)
- [_CP_readt](https://d3codex.com/cfunctions/cp-readt/)
- [_CP_weof](https://d3codex.com/cfunctions/cp-weof/)

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