CSC209H1 Lecture Notes - Data File, Errno.H, C String Handling
Document Summary
Unix has 2 main mechanisms for managing file access: file pointers: standard i/o library. Reading from file: if we want to read from somewhere other than stdin, we need to open a file. You deal with a pointer to a file structure that contains a: how should we specify the filename in a code? descriptor and a buffer. Use for regular files (more abstract and portable) Allows simple reading/writing/opening/closing: file descriptors: low-level. Each open file is identified by a small integer. Stdin, stdout, stderr: these 3 files are automatically opened for any executing program. These are global variables in the library of type file * (file streams) already open and setup everytime a program is ran: stdin: standard input = reading from the keyboard. File descriptor = 0: stdout: standard output = writing to screen. File descriptor = 1: stderr: standard rrror = write to screen for error messages. File operations: for regular files use from #include