CSC209H5 Chapter Notes - Chapter 6: Gnu Compiler Collection, Child Process, C Data Types

33 views5 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) #define max_line_length 80 int main ( int argc, char *argv[] ) { File *fp; char s [max_line_length + 1 ]; fp = fopen(argv[ 1 ], "r" ); fgets( s , max_line_length, fp); printf ( "one line from the file: %s, s); return 0; In this program, we use fopen to open the file that is given as a command line argument. Each system call returns a special value to indicate an error. System calls that return a pointer will return null if there is an error. System calls that return an integer will return -1 if there is an error. The return value itself cannot be solely used to indicate the error type. Errno has a return type of return int. When an error occurs in the system call, the system calls return. 1 or null depending on the return and sets a value for errno.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents