Presentation is loading. Please wait.

Presentation is loading. Please wait.

File handling in C By Anand George.

Similar presentations


Presentation on theme: "File handling in C By Anand George."— Presentation transcript:

1 File handling in C By Anand George

2 What is a file? A piece of memory in secondary storage or disk.
Will retain after reboot of computer or restart of the program. Memory or RAM won’t retain after program restart or reboot of computer. Secondary memory is slower than RAM.

3 Example A jpg file which is a picture.
An html page which is a file in a web server. A download program is a nothing but a group of files, say Skype or gtalk or anything like that.

4 How to create and access file in C program?
As for most of the other thing some library function. fopen – to open or create a file fread – read from the file to program memory ( variable ) fwrite – write to file from the contents of memory

5 Steps for reading Make a file using notepad. Open that file
Read from the file Print the contents of the file. Close the file

6 Steps for writing Open an empty file Initialize a character array.
Print the contents of the array ( which is memory ) to the file. Close the file Check the file using notepad if the program worked.

7 Demo Reading and writing to a file.

8 Student details program using files.
A program to do the following Accept the number of students. Accept the details of above mentioned students. Details name, id address for each student. Save the entered details to a file. Another program to Read the file and display content.

9 Demo Student details program using files.

10 Thank you


Download ppt "File handling in C By Anand George."

Similar presentations


Ads by Google