CS Behind the Curtain (CS195 2003S)
Primary:
[Front Door]
[Current]
[Glance]
-
[Blurb]
[Disabilities]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Walker/Fall 2001]
[SamR]
Back to Files. On to Designing a List Type.
Held: Friday, 7 March 2003
Summary: Today we continue our investigation into files in C.
Related Pages:
Due
Notes:
readLine
procedure that you're going to critique today.
It may be that he wrote it when he first started learning C. It may
be that he reused it from someone else. He suggests that you use it as
an example of why to be careful about legacy code.Overview:
readLine
?readLine
readLine
.
void readLine(FILE *cityFile, char line[MAX]) { /* This procedures reads a line from the given file */ int i = 0; if (fscanf(cityFile, "%c", &line[i]) == EOF) { line[0] = EOF; return; } while (line[i] != '\n') { i++; fscanf(cityFile, "%c", &line[i]); } line[i] = 0; }
line[i] = getc(cityFile)
is a more standard way of reading a
character (and is more efficient).
Back to Files. On to Designing a List Type.
Primary:
[Front Door]
[Current]
[Glance]
-
[Blurb]
[Disabilities]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Walker/Fall 2001]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri May 2 14:20:44 2003.
The source to the document was last modified on Mon Jan 20 12:41:04 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS195/2003S/Outlines/outline.28.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby