Background: Problems
Background: Problems
• Problems
• Whole data is lost once the program is terminated
• No persistent storage
• When volume of data is large it takes a lot of time to enter
the data again
• Wrongly type/entered data cannot be corrected easily
Concept of files
• File: Place on the disk where data can be stored for
later usage and alter that information whenever
necessary.
Classification of files
• Disk I/O Functions
• High Level
• Text
• Formatted
• Unformatted
• Binary
• Formatted
• Unformatted
• Low Level
Some important Functions:
• fopen(): creates a new file/Open existing file
• fclose(): closes a file which was opened for use
• fgetc(): read a character from a file
• fputc(): write a character to a file
• fprintf(): write a set of data values to a file
• fscanf(): reads a set of data values from a file
• fseek(): sets a position to a desired point in file
• ftell(): tells about the current position in the file
Opening a file
FILE *fp;
fp=fopen(“filename”,”mode”);
• https://cse.iitkgp.ac.in/~bivasm/pds_notes/
• https://www.geeksforgeeks.org/
• https://overiq.com/c-programming-101/
• https://www.oreilly.com/library/
• https://www.cs.swarthmore.edu/~newhall/cs31/resources