SlideShare a Scribd company logo
1 of 11
Presented by Rishi Ram khanal
BIM 2nd semester (TU)
Roll no:108
Contents
 Introduction
 Reading file
 Example of reading file
 Writing file
 Example of writing file
Introduction
 File is a collection of bytes on a secondary storage
device
 It is a generally disk of some kind
 Bytes may be interpreted like as character, word ,line
and paragraph
 It is simply machine decipherable storage media
where data and programs are stored
Reading file
 When r is used, the file is opened for reading
 W is used for indicate a file used for writing
 Indicates that you desire to append additional data to
the already in an existing file
 Using the r indicate that the file is assumed to be a text
file already exist
 If file not exit the fill pointer is set to be null
Examples for read
 /*program to display the contents of a fj
 #include<stdio.h>
 Void main ()
 {
 File *fopen (), *fp;
 Int c;
 Fp=fopen(“prog.c”,r);
 While (c!=edf)
 {
 Putchar (c);
 C=getch(fp);
 }
 Fclose(fp);
 }
Writing “w”
 File is opened for writing
 It will be create if it does not already exist
 It will be reset if does ,resulting in the any data already
there
 Using the w indicates that the file is assumed to be a
text file
Example
 #include<stdio.h>
 int main ()
 {
 File *fp;
 File =fopen(“file.txt”,”w”) ;
 /*create a file and a text /*
 Fprintf(fp,“%s”,”this is just an example ”) ;/*writr data
to the file /*
 Fclose(fp); /*done*/
 Return 0;
 }
C programming disk file reading and writing
C programming disk file reading and writing

More Related Content

What's hot

File organization and indexing
File organization and indexingFile organization and indexing
File organization and indexingraveena sharma
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CAshim Lamichhane
 
Introduction to the design and specification of file structures
Introduction to the design and specification of file structuresIntroduction to the design and specification of file structures
Introduction to the design and specification of file structuresDevyani Vaidya
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure ConceptsDileep Kodira
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing fileskeeeerty
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handlingpinkpreet_kaur
 
File Handling - N K Upadhyay
File Handling - N K UpadhyayFile Handling - N K Upadhyay
File Handling - N K UpadhyayDipayan Sarkar
 
File management in C++
File management in C++File management in C++
File management in C++apoorvaverma33
 
file management in c language
file management in c languagefile management in c language
file management in c languagechintan makwana
 
File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Abdullah khawar
 

What's hot (19)

File organization and indexing
File organization and indexingFile organization and indexing
File organization and indexing
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
 
Introduction to the design and specification of file structures
Introduction to the design and specification of file structuresIntroduction to the design and specification of file structures
Introduction to the design and specification of file structures
 
File handling-c
File handling-cFile handling-c
File handling-c
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure Concepts
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
 
File mangement
File mangementFile mangement
File mangement
 
Python file handling
Python file handlingPython file handling
Python file handling
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File Handling - N K Upadhyay
File Handling - N K UpadhyayFile Handling - N K Upadhyay
File Handling - N K Upadhyay
 
File management in C++
File management in C++File management in C++
File management in C++
 
file management in c language
file management in c languagefile management in c language
file management in c language
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
File structures
File structuresFile structures
File structures
 
Handling computer files
Handling computer filesHandling computer files
Handling computer files
 
file
filefile
file
 
Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)
 
File_Management_in_C
File_Management_in_CFile_Management_in_C
File_Management_in_C
 

Similar to C programming disk file reading and writing

file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.pptyuvrajkeshri
 
Files let you store data on secondary storage such as a hard disk so that you...
Files let you store data on secondary storage such as a hard disk so that you...Files let you store data on secondary storage such as a hard disk so that you...
Files let you store data on secondary storage such as a hard disk so that you...Bern Jamie
 
Switching & Multiplexing
Switching & MultiplexingSwitching & Multiplexing
Switching & MultiplexingMelkamuEndale1
 
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugevsol7206
 
Python files / directories part16
Python files / directories  part16Python files / directories  part16
Python files / directories part16Vishal Dutt
 
FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.ssuser00ad4e
 
File Handling in C Part I
File Handling in C Part IFile Handling in C Part I
File Handling in C Part IArpana Awasthi
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxarmaansohail9356
 
Chapter 13.1.10
Chapter 13.1.10Chapter 13.1.10
Chapter 13.1.10patcha535
 
Understanding c file handling functions with examples
Understanding c file handling functions with examplesUnderstanding c file handling functions with examples
Understanding c file handling functions with examplesMuhammed Thanveer M
 

Similar to C programming disk file reading and writing (20)

Python-files
Python-filesPython-files
Python-files
 
PPS PPT 2.pptx
PPS PPT 2.pptxPPS PPT 2.pptx
PPS PPT 2.pptx
 
Module 5 file cp
Module 5 file cpModule 5 file cp
Module 5 file cp
 
Module2-Files.pdf
Module2-Files.pdfModule2-Files.pdf
Module2-Files.pdf
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
Satz1
Satz1Satz1
Satz1
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
Files let you store data on secondary storage such as a hard disk so that you...
Files let you store data on secondary storage such as a hard disk so that you...Files let you store data on secondary storage such as a hard disk so that you...
Files let you store data on secondary storage such as a hard disk so that you...
 
Switching & Multiplexing
Switching & MultiplexingSwitching & Multiplexing
Switching & Multiplexing
 
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
 
Python files / directories part16
Python files / directories  part16Python files / directories  part16
Python files / directories part16
 
FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.
 
File Organization
File OrganizationFile Organization
File Organization
 
File Handling in C Part I
File Handling in C Part IFile Handling in C Part I
File Handling in C Part I
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
 
Chapter 13.1.10
Chapter 13.1.10Chapter 13.1.10
Chapter 13.1.10
 
Unit 8
Unit 8Unit 8
Unit 8
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Understanding c file handling functions with examples
Understanding c file handling functions with examplesUnderstanding c file handling functions with examples
Understanding c file handling functions with examples
 

More from rishi ram khanal

Measurement of gdp under product method
Measurement of gdp under product methodMeasurement of gdp under product method
Measurement of gdp under product methodrishi ram khanal
 
Major social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyMajor social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyrishi ram khanal
 
Introduction to artificial intelligence
Introduction to artificial intelligenceIntroduction to artificial intelligence
Introduction to artificial intelligencerishi ram khanal
 
Interview method in research
Interview method in researchInterview method in research
Interview method in researchrishi ram khanal
 
Presentation on kurtosis statistics
Presentation on kurtosis statisticsPresentation on kurtosis statistics
Presentation on kurtosis statisticsrishi ram khanal
 
Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...rishi ram khanal
 
Implementation issues software engineering
Implementation issues software engineeringImplementation issues software engineering
Implementation issues software engineeringrishi ram khanal
 
Effect of migration in developing country
Effect of migration in developing countryEffect of migration in developing country
Effect of migration in developing countryrishi ram khanal
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)rishi ram khanal
 
Goals of firm business finance
Goals of firm business financeGoals of firm business finance
Goals of firm business financerishi ram khanal
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
 
GDP and trends economics .rishi
GDP and trends economics .rishiGDP and trends economics .rishi
GDP and trends economics .rishirishi ram khanal
 
Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...rishi ram khanal
 
Field study of crystal finance share broker
Field study of crystal finance share brokerField study of crystal finance share broker
Field study of crystal finance share brokerrishi ram khanal
 
Database management system
Database management systemDatabase management system
Database management systemrishi ram khanal
 
Credential reuse cyber security
Credential reuse cyber securityCredential reuse cyber security
Credential reuse cyber securityrishi ram khanal
 

More from rishi ram khanal (20)

Measurement of gdp under product method
Measurement of gdp under product methodMeasurement of gdp under product method
Measurement of gdp under product method
 
Major social problem in nepal child labour socilology
Major social problem in nepal child labour socilologyMajor social problem in nepal child labour socilology
Major social problem in nepal child labour socilology
 
Light source ooad
Light source ooadLight source ooad
Light source ooad
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to artificial intelligence
Introduction to artificial intelligenceIntroduction to artificial intelligence
Introduction to artificial intelligence
 
Interview method in research
Interview method in researchInterview method in research
Interview method in research
 
Presentation on kurtosis statistics
Presentation on kurtosis statisticsPresentation on kurtosis statistics
Presentation on kurtosis statistics
 
Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...Importance of double entry accounting system for public limited company (basi...
Importance of double entry accounting system for public limited company (basi...
 
Implementation issues software engineering
Implementation issues software engineeringImplementation issues software engineering
Implementation issues software engineering
 
Effect of migration in developing country
Effect of migration in developing countryEffect of migration in developing country
Effect of migration in developing country
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
 
Goals of firm business finance
Goals of firm business financeGoals of firm business finance
Goals of firm business finance
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
GDP and trends economics .rishi
GDP and trends economics .rishiGDP and trends economics .rishi
GDP and trends economics .rishi
 
Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...Final internship-report on the networking department of the internet service ...
Final internship-report on the networking department of the internet service ...
 
Field study of crystal finance share broker
Field study of crystal finance share brokerField study of crystal finance share broker
Field study of crystal finance share broker
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
Computer virus and worms
Computer virus and wormsComputer virus and worms
Computer virus and worms
 
Database management system
Database management systemDatabase management system
Database management system
 
Credential reuse cyber security
Credential reuse cyber securityCredential reuse cyber security
Credential reuse cyber security
 

Recently uploaded

Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

C programming disk file reading and writing

  • 1. Presented by Rishi Ram khanal BIM 2nd semester (TU) Roll no:108
  • 2. Contents  Introduction  Reading file  Example of reading file  Writing file  Example of writing file
  • 3. Introduction  File is a collection of bytes on a secondary storage device  It is a generally disk of some kind  Bytes may be interpreted like as character, word ,line and paragraph  It is simply machine decipherable storage media where data and programs are stored
  • 4. Reading file  When r is used, the file is opened for reading  W is used for indicate a file used for writing  Indicates that you desire to append additional data to the already in an existing file  Using the r indicate that the file is assumed to be a text file already exist  If file not exit the fill pointer is set to be null
  • 5. Examples for read  /*program to display the contents of a fj  #include<stdio.h>  Void main ()  {  File *fopen (), *fp;  Int c;  Fp=fopen(“prog.c”,r);  While (c!=edf)  {
  • 6.  Putchar (c);  C=getch(fp);  }  Fclose(fp);  }
  • 7. Writing “w”  File is opened for writing  It will be create if it does not already exist  It will be reset if does ,resulting in the any data already there  Using the w indicates that the file is assumed to be a text file
  • 8. Example  #include<stdio.h>  int main ()  {  File *fp;  File =fopen(“file.txt”,”w”) ;  /*create a file and a text /*  Fprintf(fp,“%s”,”this is just an example ”) ;/*writr data to the file /*