# C/C++ quickstart
This is a ~60-second round-trip in C/C++: snapshot a directory, `push` it to a
local `file://` store, then `pull` it back and confirm the ID matches. Snapshot
IDs are 64-character lowercase hex and are bit-identical to the CLI and every
other binding.
## 1. Install
Build the `snapdir-ffi` C ABI from crates.io and compile against `snapdir.hpp` —
see [Install snapdir for C/C++](/install/cpp/) for the full recipe:
```sh
cargo build --release # -> target/release/libsnapdir_ffi.a
cbindgen --config cbindgen.toml --crate snapdir-ffi --output snapdir.h .
g++ -std=c++20 roundtrip.cpp -I. -L. -lsnapdir_ffi -lpthread -ldl -lm -o roundtrip
```
## 2. Snapshot + push
Compute the snapshot ID of a directory, then push it to a local store. The store
URI is always an argument; `file://$PWD/store` needs no setup.
```cpp
#include
#include
#include
#include
int main() {
const std::string dir = "./my-dir";
const std::string store = std::string("file://") + std::getenv("PWD") + "/store";
// Synchronous id — the 64-char lowercase hex snapshot id.
std::cout << "id: " << snapdir::id(dir) << '\n';
// Async push returns std::future; .get() resolves or throws.
const std::string id = snapdir::push(dir, store).get();
std::cout << "push: " << id << '\n'; //
}
```
## 3. Pull it back
Pull the snapshot into a fresh directory and recompute its ID — it matches the
one you pushed.
```cpp
snapdir::pull(id, store, "./restored").get();
const std::string back = snapdir::id("./restored");
std::cout << (back == id ? "match" : "MISMATCH") << ": " << back << '\n';
```
The `id` you get here is the same snapshot id the CLI prints for `snapdir id` and
`snapdir push` — every binding agrees byte-for-byte.