c-21

Post on 19-Jan-2015

50 Views

Category:

Education

6 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Lecture 21Lecture 21Version 1.0Version 1.0

Introduction to Introduction to File I/OFile I/O

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

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.

4Rushdi Shams, Dept of CSE, KUET, Bangladesh

5Rushdi Shams, Dept of CSE, KUET, Bangladesh

6Rushdi Shams, Dept of CSE, KUET, Bangladesh

7Rushdi Shams, Dept of CSE, KUET, Bangladesh

8Rushdi Shams, Dept of CSE, KUET, Bangladesh

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

10Rushdi Shams, Dept of CSE, KUET, Bangladesh

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

12Rushdi Shams, Dept of CSE, KUET, Bangladesh

top related