COMP 206 Lecture Notes - Lecture 16: Data File, Carriage Return, Scanf Format String

28 views2 pages

Document Summary

Eof: end of file is returned by input functions when they can no longer give useful input. Usually used to end lines in unix text files. \r: carriage return ( mainly not used in unix ) Can read single character from a file, but we must have some error messages ex. If the next character is the end of a file. Always check to make sure file pointer is not null. All scanf returns the number of things" it has read for you (however many of the %(d,s,etc. ) exist) Tests to end reading in order to end the reading of a while loop, you must use eof while (((c = getchar()) != \n) && (c != eof) putchar(c); if(c != eof) putchar(c); Read until end of file: while((c=getchar()) != eof) Read from a file until end of file: while((c=fgetc(filehandle)) != eof) Read until end of line: while ((c = getchar()) != \n)

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