# _CP_open

_CP_open is equivalent to the `open *string1*,*string2* to *fd*` BASIC statement.

## Syntax

```
int _CP_open(int* fd, CPSTR* string1, CPSTR* string2)
```
Upon successful return, the first parameter is a pointer
to an integer file descriptor that can be passed to other file system
calls.

## Parameter(s)

| string1 | Should be dict or data, or can be passed as _CP_str_null. |
| --- | --- |
| string2 | Should be the file name. |

## Description

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

## Example(s)

```
CPSTR * s = _CP_mkstr("myfile");
int f;

_CP_open(&f,_CP_str_null,s);
_CP_clearfile(f);
_CP_close(f);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)
- [_CP_close](https://d3codex.com/cfunctions/cp-close/)
- [_CP_release](https://d3codex.com/cfunctions/cp-release/)
- [_CP_replace_bridge](https://d3codex.com/cfunctions/cp-replace-bridge/)
- [_CP_write](https://d3codex.com/cfunctions/cp-write/)
- [_CP_writev](https://d3codex.com/cfunctions/cp-writev/)

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