---
name: "sc_connect_card"
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_connect_card"
---

# sc\_connect\_card(3)

Connect to smart card in reader

## NAME

sc\_connect\_card - Connect to smart card in reader

## SYNOPSIS

```
#include <opensc.h>
int sc_connect_card(sc_reader_t *reader, int slot, sc_card_t **card);
```

## DESCRIPTION

This function connects to a card in a reader, resets the card and retrieves the ATR (Answer To Reset). Based on the ATR, it tries to auto-detect which card driver to use.

The *slot* parameter identifies the card reader´s slot. Slots are numbered consecutively, starting at 0.

If OpenSC was able to connect to the card, a pointer to the sc\_card\_t object is stored in the location pointer to by the *card* parameter. The card handle should be released with sc\_disconnect\_card when no longer in use.

## RETURN VALUE

Returns 0 if successful, or a negative value in case of error.
