Tuesday, April 14, 2026

Files in Pseudocode

Writing to a file 

OPENFILE <filename> FOR WRITE  

WRITEFILE <filename>, <data>  

CLOSEFILE <filename>  

- Opens a file for writing.  

- Writes data into the file.  

- Closes the file after writing.  

Reading from a file  

OPENFILE <filename> FOR READ  

READFILE <filename>, <variable>  

CLOSEFILE <filename>  

- Opens a file for reading.  

- Reads a line and stores the value in a variable.  

- Closes the file after reading.  

Appending to a file  

OPENFILE <filename> FOR APPEND  

WRITEFILE <filename>, <data>  

CLOSEFILE <filename>  

- Opens a file for appending.  

- Adds new data at the end of the file.  

- Closes the file after appending.  

Concept of EOF (End of File) 

- EOF is used when reading a file from beginning to end.  

- It indicates that there is no more data left to read.  

- Helps prevent errors when trying to read beyond the file’s content.  

No comments:

Folk Arts of India

Madhubani Painting   - Region: Mithila, Bihar   - Period: Ancient (references from Ramayana)   - Artists: Traditionally, women   - Themes...