ENGM 1081 Lecture Notes - Lecture 5: Data File

27 views2 pages
Verified Note

Document Summary

Declaring files: file* fin; - for input files, file* fout; -for output files. A variable type file* (file pointer) which references the document which we either wish to read or write to is in the computer system. Thus, we could say that "fin" and "fout" are file pointer variables that give the program direction to the files we wish to interact with as part of our program. Opening an input file to be read fin = fopen("file_being_read. txt","r"); Opening an output file to write fout = fopen("file_being_written_to. txt","w"); Opening an output file to append fout = fopen("file_being_appended. txt","a"); Writing versus appending: when we write to a file, we generate a new file with the exact file name and extension identified in fopen() located in the directory where we have saved the program. If the file does not yet exist (for example, during the first time running the program) then a new file will be created as normal.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents