SlideShare a Scribd company logo
1 of 11
Presented by
Rifatu Jaman
Id: 222015032
Adnan al-emran ontor
Id: 222015033
1
Presented To
MR. S. M. RASHIDUL HASAN NIJHUM
Lecturer of GUB
start
Topic: File operation in C
programming
2
Instructions
Why files are needed?
• When a program is terminated, the entire data is lost. Storing
in a file will preserve your data even if the program terminates.
• If you have to enter a large number of data, it will take a lot of
time to enter them all.
However, if you have a file containing all the data, you can easily
access the contents of the file using a few commands in C.
• You can easily move your data from one computer to another
without any changes.
File operation
3
Types
Types of Files
When dealingwith files, there are two types of files you
should know about:
1
Text files
2
Binary files
File operation
4
File Operations
In C, you can perform four major operations on files, either text or
binary:
1.Creating a new file
2.Opening an existing file
3.Closing a file
4.Reading from and writing information to a file
File Operations
File operation
Declaration of file
-------- ----------------------
FILE *name_of_file;
File Declaration
5
Opening Modes in Standard I/O
Mode Meaning of Mode During Inexistence of file
r Open for reading. If the filedoes not exist, fopen() returns NULL.
rb
Open for reading in binary mode.
If the filedoes not exist, fopen() returns NULL.
w
Open for writing.
If the fileexists, its contents are overwritten.
If the filedoes not exist, it willbe created.
wb
Open for writing in binary mode.
If the fileexists, its contents are overwritten.
If the filedoes not exist, it willbe created.
a Open for append.
Data is addedto the end of the file.
If the filedoes not exist, it willbe created.
ab Open for append in binary mode.
Data is addedto the end of the file.
If the filedoes not exist, it willbe created.
r+ Open for both reading and writing. If the filedoes not exist, fopen() returns NULL.
rb+ Open for both reading and writing in binary mode. If the fileexists, its contents are overwritten.
If the filedoes not exist, it willbe created.
w+ Open for both reading and writing. If the fileexists, its contents are overwritten.
If the filedoes not exist, it willbe created.
wb+ Open for both reading and writing in binary mode. If the fileexists, its contents are overwritten.
a+ Open for both reading and appending. If the filedoes not exist, it willbe created.
ab+ Open for both reading and appendingin binary
mode.
If the filedoes not exist, it willbe created.
6
Opening a file
The basic file operations are
fopen - open a file
fclose - close an opened file
fread - read from a file
fwrite - write to a file
fseek/fsetpos - move a file pointer to somewhere in a
file.
ftell/fgetpos - tell you where the file pointer is
located.
7
fputc()
The fputc() function is used to write a single character into file. It outputs a
character to a stream.
Syntax:
int fputc(int c, FILE *stream)
fputc()
File operation
Example:
#include <stdio.h>
main(){
FILE *fp;
fp = fopen("file1.txt", "w"); //opening file
fputc('a',fp); //writing single character into file
fclose(fp); //closing file
}
file1.txt
a
8
fgetc()
The fgetc() function returns a single character from the file. It gets a character
from the stream. It returns EOF at the end of file.
Syntax:
int fgetc(FILE *stream)
fgetc()
File operation
#include<stdio.h>
#include<conio.h>
void main(){
FILE *fp;
char c;
fp=fopen("myfile.txt","r");
while((c=fgetc(fp))!=EOF){
printf("%c",c);
}
fclose(fp); //means file close
}
myfile.txt
green
university
this is simple text message
Output :
green university
fseek()
Random Access to file in C
• Random access means we can move to any part of a file and read or write
data from it without having to read through the complete file. We can access
the data stored in the file in two ways.
• Sequentially
• Randomly
Example: fseek(), ftell(), rewind()
File operation 9
10
conclusion
Questions and
answers
Conclusio
n
File operation
References
https://www.w3schools.in/c-programming/file-handling
https://www.programiz.com/c-programming/c-file-input-output
So we can say, it is used to save program data permanently and it is an
important topic of C program.
References book :
11
end
Thank You

File operation
---------and Happy coding

More Related Content

Similar to Topic - File operation.pptx

File handing in C
File handing in CFile handing in C
File handing in Cshrishcg
 
C 檔案輸入與輸出
C 檔案輸入與輸出C 檔案輸入與輸出
C 檔案輸入與輸出PingLun Liao
 
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugevsol7206
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.pptyuvrajkeshri
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxAssadLeo1
 
File handling and Dictionaries in python
File handling and Dictionaries in pythonFile handling and Dictionaries in python
File handling and Dictionaries in pythonnitamhaske
 
File Management
File ManagementFile Management
File Managementjani parth
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdfRashmiAngane1
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5YOGESH SINGH
 
File Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptFile Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptRaja Ram Dutta
 
File Handling in C Part I
File Handling in C Part IFile Handling in C Part I
File Handling in C Part IArpana Awasthi
 

Similar to Topic - File operation.pptx (20)

File handing in C
File handing in CFile handing in C
File handing in C
 
C 檔案輸入與輸出
C 檔案輸入與輸出C 檔案輸入與輸出
C 檔案輸入與輸出
 
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
Module 5 file cp
Module 5 file cpModule 5 file cp
Module 5 file cp
 
File accessing modes in c
File accessing modes in cFile accessing modes in c
File accessing modes in c
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptx
 
File handling and Dictionaries in python
File handling and Dictionaries in pythonFile handling and Dictionaries in python
File handling and Dictionaries in python
 
File Management
File ManagementFile Management
File Management
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdf
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
 
File management
File managementFile management
File management
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 
File Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptFile Handling as 08032021 (1).ppt
File Handling as 08032021 (1).ppt
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
 
File Handling in C Part I
File Handling in C Part IFile Handling in C Part I
File Handling in C Part I
 

More from Adnan al-emran

“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি
“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি
“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতিAdnan al-emran
 
Application of Linear Algebra in Real Life
Application of Linear Algebra in Real LifeApplication of Linear Algebra in Real Life
Application of Linear Algebra in Real LifeAdnan al-emran
 
Random-Access-Memory-and-Memory-Related-Technologies.pptx
Random-Access-Memory-and-Memory-Related-Technologies.pptxRandom-Access-Memory-and-Memory-Related-Technologies.pptx
Random-Access-Memory-and-Memory-Related-Technologies.pptxAdnan al-emran
 
artificial intelligence (ai)
artificial intelligence (ai)artificial intelligence (ai)
artificial intelligence (ai)Adnan al-emran
 
Application of Differential Calculus (math-101) .pptx
Application of Differential Calculus (math-101) .pptxApplication of Differential Calculus (math-101) .pptx
Application of Differential Calculus (math-101) .pptxAdnan al-emran
 
Electricity Full lecture.pptx
Electricity Full lecture.pptxElectricity Full lecture.pptx
Electricity Full lecture.pptxAdnan al-emran
 
Physics In Daily Life (Phy 103)
Physics In Daily Life (Phy 103) Physics In Daily Life (Phy 103)
Physics In Daily Life (Phy 103) Adnan al-emran
 

More from Adnan al-emran (8)

“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি
“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি
“বাংলার মুখ ” কবিতা অবলম্বনে কবির অনুভূতি
 
Application of Linear Algebra in Real Life
Application of Linear Algebra in Real LifeApplication of Linear Algebra in Real Life
Application of Linear Algebra in Real Life
 
Random-Access-Memory-and-Memory-Related-Technologies.pptx
Random-Access-Memory-and-Memory-Related-Technologies.pptxRandom-Access-Memory-and-Memory-Related-Technologies.pptx
Random-Access-Memory-and-Memory-Related-Technologies.pptx
 
artificial intelligence (ai)
artificial intelligence (ai)artificial intelligence (ai)
artificial intelligence (ai)
 
EAP.pptx
EAP.pptxEAP.pptx
EAP.pptx
 
Application of Differential Calculus (math-101) .pptx
Application of Differential Calculus (math-101) .pptxApplication of Differential Calculus (math-101) .pptx
Application of Differential Calculus (math-101) .pptx
 
Electricity Full lecture.pptx
Electricity Full lecture.pptxElectricity Full lecture.pptx
Electricity Full lecture.pptx
 
Physics In Daily Life (Phy 103)
Physics In Daily Life (Phy 103) Physics In Daily Life (Phy 103)
Physics In Daily Life (Phy 103)
 

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 

Recently uploaded (20)

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 

Topic - File operation.pptx

  • 1. Presented by Rifatu Jaman Id: 222015032 Adnan al-emran ontor Id: 222015033 1 Presented To MR. S. M. RASHIDUL HASAN NIJHUM Lecturer of GUB start Topic: File operation in C programming
  • 2. 2 Instructions Why files are needed? • When a program is terminated, the entire data is lost. Storing in a file will preserve your data even if the program terminates. • If you have to enter a large number of data, it will take a lot of time to enter them all. However, if you have a file containing all the data, you can easily access the contents of the file using a few commands in C. • You can easily move your data from one computer to another without any changes. File operation
  • 3. 3 Types Types of Files When dealingwith files, there are two types of files you should know about: 1 Text files 2 Binary files File operation
  • 4. 4 File Operations In C, you can perform four major operations on files, either text or binary: 1.Creating a new file 2.Opening an existing file 3.Closing a file 4.Reading from and writing information to a file File Operations File operation Declaration of file -------- ---------------------- FILE *name_of_file; File Declaration
  • 5. 5 Opening Modes in Standard I/O Mode Meaning of Mode During Inexistence of file r Open for reading. If the filedoes not exist, fopen() returns NULL. rb Open for reading in binary mode. If the filedoes not exist, fopen() returns NULL. w Open for writing. If the fileexists, its contents are overwritten. If the filedoes not exist, it willbe created. wb Open for writing in binary mode. If the fileexists, its contents are overwritten. If the filedoes not exist, it willbe created. a Open for append. Data is addedto the end of the file. If the filedoes not exist, it willbe created. ab Open for append in binary mode. Data is addedto the end of the file. If the filedoes not exist, it willbe created. r+ Open for both reading and writing. If the filedoes not exist, fopen() returns NULL. rb+ Open for both reading and writing in binary mode. If the fileexists, its contents are overwritten. If the filedoes not exist, it willbe created. w+ Open for both reading and writing. If the fileexists, its contents are overwritten. If the filedoes not exist, it willbe created. wb+ Open for both reading and writing in binary mode. If the fileexists, its contents are overwritten. a+ Open for both reading and appending. If the filedoes not exist, it willbe created. ab+ Open for both reading and appendingin binary mode. If the filedoes not exist, it willbe created.
  • 6. 6 Opening a file The basic file operations are fopen - open a file fclose - close an opened file fread - read from a file fwrite - write to a file fseek/fsetpos - move a file pointer to somewhere in a file. ftell/fgetpos - tell you where the file pointer is located.
  • 7. 7 fputc() The fputc() function is used to write a single character into file. It outputs a character to a stream. Syntax: int fputc(int c, FILE *stream) fputc() File operation Example: #include <stdio.h> main(){ FILE *fp; fp = fopen("file1.txt", "w"); //opening file fputc('a',fp); //writing single character into file fclose(fp); //closing file } file1.txt a
  • 8. 8 fgetc() The fgetc() function returns a single character from the file. It gets a character from the stream. It returns EOF at the end of file. Syntax: int fgetc(FILE *stream) fgetc() File operation #include<stdio.h> #include<conio.h> void main(){ FILE *fp; char c; fp=fopen("myfile.txt","r"); while((c=fgetc(fp))!=EOF){ printf("%c",c); } fclose(fp); //means file close } myfile.txt green university this is simple text message Output : green university
  • 9. fseek() Random Access to file in C • Random access means we can move to any part of a file and read or write data from it without having to read through the complete file. We can access the data stored in the file in two ways. • Sequentially • Randomly Example: fseek(), ftell(), rewind() File operation 9