12
Lecture 21 Lecture 21 Version 1.0 Version 1.0 Introduction to Introduction to File I/O File I/O

C-21

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: C-21

Lecture 21Lecture 21Version 1.0Version 1.0

Introduction to Introduction to File I/OFile I/O

Page 2: C-21

2Rushdi Shams, Dept of CSE, KUET, Bangladesh

Different operations on Different operations on filesfiles

1.1. Creation of a new file Creation of a new file

2.2. Opening an existing file Opening an existing file

3.3. Reading from a file Reading from a file

4.4. Writing to a file Writing to a file

5.5. Moving to a specific location in a Moving to a specific location in a file (seeking) file (seeking)

6.6. Closing a file Closing a file

Page 3: C-21

3Rushdi Shams, Dept of CSE, KUET, Bangladesh

Various file concepts from Various file concepts from one programone program

Now, we will see various concepts Now, we will see various concepts on files from just one program.on files from just one program.

Page 4: C-21

4Rushdi Shams, Dept of CSE, KUET, Bangladesh

Page 5: C-21

5Rushdi Shams, Dept of CSE, KUET, Bangladesh

Page 6: C-21

6Rushdi Shams, Dept of CSE, KUET, Bangladesh

Page 7: C-21

7Rushdi Shams, Dept of CSE, KUET, Bangladesh

Page 8: C-21

8Rushdi Shams, Dept of CSE, KUET, Bangladesh

Page 9: C-21

9Rushdi Shams, Dept of CSE, KUET, Bangladesh

Error opening file??Error opening file??

While opening the file in “r” mode, While opening the file in “r” mode, this may happen because the file this may happen because the file being opened may not be present on being opened may not be present on the disk at all the disk at all

Page 10: C-21

10Rushdi Shams, Dept of CSE, KUET, Bangladesh

Page 11: C-21

11Rushdi Shams, Dept of CSE, KUET, Bangladesh

Now we will write a program that Now we will write a program that counts Character, newlines, blank counts Character, newlines, blank spaces and tabs from a filespaces and tabs from a file

Page 12: C-21

12Rushdi Shams, Dept of CSE, KUET, Bangladesh