---
name: "sc_write_binary"
section: "3"
platform: "linux"
package: "libopensc2-dev"
version: "0.11.13-1.1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_write_binary"
---

# sc\_write\_binary(3)

Write to a new file

## NAME

sc\_write\_binary - Write to a new file

## SYNOPSIS

```
#include <opensc.h>
int sc_write_binary(struct sc_card *card, unsigned int offset,
                    const unsigned char *buf, size_t count,
                    unsigned long flags);
```

## DESCRIPTION

This function writes *count* bytes from the buffer pointed to by *buf* to a transparent elementary file (EF) on *card*. It corresponds to the ISO 7816 WRITE BINARY function. Call sc\_select\_file() first to select the file to write to.

This function is used to write to a newly created file, or to a a previously unused portion of a file. For updating an existing file, use the sc\_update\_binary() function.

The *offset* argument specifies the file offset in bytes. The *flags* argument is currently not used, and should be set to 0.

## RETURN VALUE

If successful, the number of bytes written is returned. Otherwise, a negative value is returned.
