Skip to content

Suhita2005/FILE-HANDLING-PROGRAM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

File Handling Program

Overview

This C program demonstrates fundamental file operations including creating, reading, writing, and appending data to files.

Features

  • Create Files: Create new empty files
  • Write Files: Write content to files (overwrites existing content)
  • Read Files: Read and display file contents
  • Append Files: Add content to the end of existing files

File Structure

task 1/
├── file handling.c      # Main source code
├── file handling.exe    # Compiled executable
└── README.md           # This documentation

Compilation

gcc "file handling.c" -o "file handling.exe"

Usage

Run the executable and follow the menu-driven interface:

  1. Create a new file: Creates an empty file with the specified name
  2. Write to a file: Writes content to a file (overwrites existing content)
  3. Read from a file: Displays the current contents of a file
  4. Append to a file: Adds content to the end of an existing file
  5. Exit: Terminates the program

Example Workflow

  1. Choose option 1 to create a new file (e.g., "test.txt")
  2. Choose option 2 to write initial content to the file
  3. Choose option 3 to read and verify the content
  4. Choose option 4 to append additional content
  5. Choose option 3 again to see the updated content
  6. Choose option 5 to exit

Technical Details

  • Language: C
  • Libraries: stdio.h, stdlib.h, string.h
  • Buffer Size: 1000 characters for content input
  • File Modes:
    • "w" for write/create operations
    • "r" for read operations
    • "a" for append operations

Error Handling

The program includes error checking for:

  • File creation failures
  • File opening errors for read/write/append operations
  • Invalid menu selections

Notes

  • Files are created in the same directory as the executable
  • Maximum content length per operation is 999 characters
  • The program uses fgets() for safe string input handling

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages