# ftell

Returns the offset of the current byte relative to the beginning of a file.

## 📝 Syntax

* p = ftell(fid)

## 📥 Input argument

* fid - a file descriptor

## 📤 Output argument

* p - an integer value: position of the file pointer as the number of characters from the beginning of the file.

## 📄 Description

ftell returns the offset of the current byte relative to the beginning of the file associated with the named stream fid.

## 💡 Example

```matlab
TXT = 'example about ftell.';
fileID = fopen([tempdir(), 'ftell.txt'],'wt');
fprintf(fileID, TXT);
p1 = ftell(fileID)
fseek(fileID, SEEK_CUR, 'bof');
p2 = ftell(fileID)
status = fclose(fileID);
```

## 🔗 See also

[fopen](/nelson/markdown/en/stream_manager/fopen.md), [fprintf](/nelson/markdown/en/stream_manager/fread.md), [fclose](/nelson/markdown/en/stream_manager/fclose.md), [fseek](/nelson/markdown/en/stream_manager/fseek.md).

## 🕔 History

| Version | 📄 Description  |
| ------- | --------------- |
| 1.0.0   | initial version |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nelson-9.gitbook.io/nelson/markdown/en/stream_manager/ftell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
