From the course: C Programming: Exploring Advanced Concepts and Practical Applications

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Opening the terminal

Opening the terminal

- [Instructor] In the Linux operating system, everything is a file, including the terminal window. It exists as a device with a file name and a full path name. At the command prompt you can type the TTY command to obtain the name. Here, the file representing the terminal is dev/pts/9. In this C program, the TTY name function obtains the same information. This function is prototyped in the uni standard header file. The TTY name functions argument is a file descriptor, not a file handle. In the code, you see the STD out file no constant used to represent the standard output devices file descriptor. This function returns a string, which is saved in the term variable and output in the following printf statement. The code confirms the terminal output. Now it changes here probably due to the way code spaces is implemented, but on a Linux computer, the terminal numbers will be the same. This update to the code uses the string return stored in variable temp to open the terminal as a file for…

Contents