# %ttyname() function

The %ttyname() function returns a pointer
to a static area containing the null terminated path name of the terminal
device associated to the file descriptor *fd*.

**For Windows:**Not Supported

## Syntax

```
ptr = (char*)%ttyname(fd)
```

## Description

If *fd* does
not describe a device in the /dev directory,
a null pointer is returned.

When run on a phantom process, this
function returns a null pointer.

Note: The return value points
to static data which is overwritten by each call. The name must be
copied, as in the example, to a D3 variable. When run on a phantom
process, a null is returned.

## Example(s)

```
char buffer[32]
* Get the device name associated to our standard input
ptr=(char*)%ttyname(0)
if ptr=0 then
* This is not a terminal (pipe?)
 return
end
* Copy the data from the static string to Pick
char buffer[32]
%strcpy(buffer, (char*)ptr)
mytty=field(buffer, char(0), 1)
```

## See also

- [%close() function](https://d3codex.com/pickbasic-flashbasic/percent-close-function/)
- [%ioctl() function](https://d3codex.com/pickbasic-flashbasic/percent-ioctl-function/)
- [%open() function](https://d3codex.com/pickbasic-flashbasic/percent-open-function/)
- [%read() function](https://d3codex.com/pickbasic-flashbasic/percent-read-function/)
- [%write() function](https://d3codex.com/pickbasic-flashbasic/percent-write-function/)
- [FlashBASIC C functions overview](https://d3codex.com/pickbasic-flashbasic/flashbasic-c-functions-overview/)

---
Source: https://d3codex.com/pickbasic-flashbasic/percent-ttyname-function/ - part of the D3Codex reference.
