Professional Documents
Culture Documents
L 11 (May - 1 - 2016)
L 11 (May - 1 - 2016)
Lecture #11
Spring 2016
2
I/O File Stream Objects and Functions ASTU
3
I/O File Stream Objects and Functions ASTU
4
File Stream Objects ASTU
5
ASTU
File Stream Objects
• For each file your program uses,
regardless of file’s type, a distinct file
stream object must be created
6
File Stream Functions ASTU
8
File Stream Functions ASTU
9
Example 1 ASTU
10
ASTU
11
Example 2 ASTU
12
Example 2: Testing ASTU
13
Closing a File ASTU
16
Reading from a Text File ASTU
17
Example 4 ASTU
18
Standard Device Files ASTU
19
Random File Access ASTU
21
Random File Access ASTU
22
Random File Access ASTU
24
Example 5: Using seekg() and tellg() ASTU
T h e g r a d e w a s 9 2 . 5 EOF
25
File Streams as Function Arguments ASTU
26
Example 7: File Streams as Function Arguments ASTU
27
Example 7: File Streams as Function Arguments ASTU
28
Case Study: Weather Forecast File Updates ASTU
29
Case Study: Weather Forecast File Updates ASTU
• Develop a Solution
32
Case Study: Weather Forecast File Updates ASTU
33
Case Study: Weather Forecast File Updates ASTU
34
Case Study: Weather Forecast File Updates ASTU
35
Case Study: Weather Forecast File Updates ASTU
36
Case Study: Weather Forecast File Updates ASTU
37
Testing the Program ASTU
38
Testing the Program ASTU
weather.in weather.out
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
S a t 3 0 A p r 1 9 ° C LF LF
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
S u n 1 M a y 1 7 ° C LF LF
39
Looking ASCII Codes Using get Function ASTU
40