FILE INPUT/OUTPUT (LOAD AND SAVE)
- Where do computers store information?
- Difference between memory and disk storage
3 ways to interact with a file
- Write to a file
- Append to a file
- Read from a file
WRITING DATA TO A FILE - SAVE COMMAND
- save command to write format:
- save command example:
- save command overwrites:
APPENDING DATA TO A FILE - SAVE COMMAND
- save command for appending instead of overwriting:
- save command for appending data with different columns:
READING FROM A FILE - LOAD COMMAND
- we want to load junk.dat
- load command
LOWER LEVEL FILE I/O FUNCTIONS
OPENING AND CLOSING A FILE
- fopen() function:
- fopen() format:
- fopen() example:
- fclose()
READING FROM FILES USING FGETl
- fgetl vs fgets:
- fgetl format:
WRITING AND APPENDING TO FILE
- fprintf function - to print formatted text into file:
- type function - checking the content of the resulting text file:
- setting the wrong permission:
ALTERNATE FILE INPUT FUNCTIONS
FSCANF
- fscanf function:
- file example (temperatures.txt):
- why won’t the load function work in this example?
- fgetl to read the header information:
- fscanf format: