# std::fgetpos

> C++ Atlas: `cppatlas.com/w/cpp/io/c/fgetpos` | Source: https://en.cppreference.com/w/cpp/io/c/fgetpos | Domain: Input/output

Obtains the file position indicator and the current parse state (if any) for the file stream stream and stores them in the object pointed to by pos.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <cstdio>
int fgetpos( std::FILE* stream, std::fpos_t* pos );
```

Obtains the file position indicator and the current parse state (if any) for the file stream `stream` and stores them in the object pointed to by `pos`. The value stored is only meaningful as the input to `std::fsetpos`.

### Parameters

- `stream` - file stream to examine
- `pos` - pointer to a `fpos_t` object to store the file position indicator to

### Return value

`​0​` upon success, nonzero value otherwise. Also sets `errno` on failure.

### Example

> Note: This section is incomplete Reason: no example

### See also

- [`ftell`](https://en.cppreference.com/w/cpp/io/c/ftell): returns the current file position indicator (function)
- [`fseek`](https://en.cppreference.com/w/cpp/io/c/fseek): moves the file position indicator to a specific location in a file (function)
- [`fsetpos`](https://en.cppreference.com/w/cpp/io/c/fsetpos): moves the file position indicator to a specific location in a file (function)
- [C documentation for `fgetpos`](https://en.cppreference.com/w/c/io/fgetpos)

---
Attribution: content from https://en.cppreference.com/w/cpp/io/c/fgetpos (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.