SlideShare une entreprise Scribd logo
1  sur  18
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Week Target Achieved
1 30 20
2 30 21
3 30
Typing Speed
File handling in c
Yasirmusthafapp
yasirmusthafapp@gmail.com
www.facebook.com/yasirmusthafa
twitter.com/yasirmusthafapp
in.linkedin.com/in/yasirmusthafapp
8891396749
Console application
• Traditional I/O system
• Text based interface(black windows screen)
• User executes the program and output
displayed on the screen
Draw back of traditional I/O
• Data is temporary
• Not available during re-execution
Introduction to file handling
• Data is stored onto the disk
• Retrieve whenever required
• Output –stored on to the disk
File
• Sequence of bytes where group of related
data is stored
• Collection of bytes interpreted as
Single character
Single word
Single line
Complete structure
File (conti)
• Last byte of file contains end of file character
(EOF)
• Can be used to check to know the end
• Structure pointer of file type –to declare a file
Eg:-FILE *fp
Fp=fopen();
File handling
• Fopen() -create or open a file
• Fclose() -close a file
• Getc() -reads a character from a file
• Putc() -writes a character to a file
• Fscanf() -reads a set of data from a file
• Fprintf() -writes a set of data to a file
• Getw() -reads an integer from a file
• Putw() -writes an integer to a file
• Fseek() -set the position to desire point
• Ftell() -gives current position in the file
• Rewind() -set the position to the begning
Two kindes of files
• Text(ASCII)
• Binary(non ASCII)
-image,audio,vedio,executable,etc
Fopen()
• To create a new file or to open an existing file
Syntax
Fopen(filename,mode);
Eg:-fp=fopen(“data.txt”,”r”);
Return NULL-unable to open
modes
1. r –opens file for reading
2. w-creates a file writing , over writes on previous
content(delete)
3. a-opens a file for appending-writing on the end
of file
• “+” character-read & write
• Can add a “b” character(non asci) –file is a binary
-”rb” , ”wb” or “ab”
Fclose()
• Close an opened file
Syntax
Fclose(pointer_name);
Eg:-fclose(fp);
• Return zero on success
• Return EOF on error
Writing to a file&Reading data from a
file
Fprintf() & fscanf()
• Just like printf() & scanf()
Eg:-fprintf(fp,”babtra”);
Eg:-fscanf(fp,”%s”,variable);
• Except-first argument:file pointer
Fputs()&fgets()
Fputc()&fgetc()
Example
#include<stdio.h>
void main()
{
char name[50];
FILE *fp;
fp=fopen("yasir.txt","r+");
fprintf(fp,"hello_yasirn");
rewind(fp);
fscanf(fp,"%s",name);
printf("%s",name);
fclose(fp);
}
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
NIT-TBI,
NIT Campus, Kozhikode,
Kerala, India.

Contenu connexe

Tendances

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
Muhammed Thanveer M
 

Tendances (20)

File in C language
File in C languageFile in C language
File in C language
 
file
filefile
file
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File handling in 'C'
File handling in 'C'File handling in 'C'
File handling in 'C'
 
File handling-c
File handling-cFile handling-c
File handling-c
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File Management
File ManagementFile Management
File Management
 
C programming file handling
C  programming file handlingC  programming file handling
C programming file handling
 
file management in c language
file management in c languagefile management in c language
file management in c language
 
File Handling in C
File Handling in C File Handling in C
File Handling in C
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
 
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
 
File Handling and Command Line Arguments in C
File Handling and Command Line Arguments in CFile Handling and Command Line Arguments in C
File Handling and Command Line Arguments in C
 
File Management in C
File Management in CFile Management in C
File Management in C
 
File_Management_in_C
File_Management_in_CFile_Management_in_C
File_Management_in_C
 
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
 
Files in C
Files in CFiles in C
Files in C
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 

Similaire à File handling in c

C-Programming Chapter 5 File-handling-C.ppt
C-Programming Chapter 5 File-handling-C.pptC-Programming Chapter 5 File-handling-C.ppt
C-Programming Chapter 5 File-handling-C.ppt
ssuserad38541
 

Similaire à File handling in c (20)

Programming in C Session 4
Programming in C Session 4Programming in C Session 4
Programming in C Session 4
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 
File management
File managementFile management
File management
 
File handing in C
File handing in CFile handing in C
File handing in C
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
C-Programming Chapter 5 File-handling-C.ppt
C-Programming Chapter 5 File-handling-C.pptC-Programming Chapter 5 File-handling-C.ppt
C-Programming Chapter 5 File-handling-C.ppt
 
File mangement
File mangementFile mangement
File mangement
 
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdfEASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
 
637225560972186380.pdf
637225560972186380.pdf637225560972186380.pdf
637225560972186380.pdf
 
Reading and Writing Files
Reading and Writing FilesReading and Writing Files
Reading and Writing Files
 
Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O
 
File handling and Dictionaries in python
File handling and Dictionaries in pythonFile handling and Dictionaries in python
File handling and Dictionaries in python
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
FILES IN C
FILES IN CFILES IN C
FILES IN C
 
Python file handling
Python file handlingPython file handling
Python file handling
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Engineering Computers L34-L35-File Handling.pptx
Engineering Computers L34-L35-File Handling.pptxEngineering Computers L34-L35-File Handling.pptx
Engineering Computers L34-L35-File Handling.pptx
 
PPS PPT 2.pptx
PPS PPT 2.pptxPPS PPT 2.pptx
PPS PPT 2.pptx
 
Unit5
Unit5Unit5
Unit5
 
Data file handling
Data file handlingData file handling
Data file handling
 

Plus de baabtra.com - No. 1 supplier of quality freshers

Plus de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

File handling in c

  • 1.
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Week Target Achieved 1 30 20 2 30 21 3 30 Typing Speed
  • 4. File handling in c Yasirmusthafapp yasirmusthafapp@gmail.com www.facebook.com/yasirmusthafa twitter.com/yasirmusthafapp in.linkedin.com/in/yasirmusthafapp 8891396749
  • 5. Console application • Traditional I/O system • Text based interface(black windows screen) • User executes the program and output displayed on the screen
  • 6. Draw back of traditional I/O • Data is temporary • Not available during re-execution
  • 7. Introduction to file handling • Data is stored onto the disk • Retrieve whenever required • Output –stored on to the disk
  • 8. File • Sequence of bytes where group of related data is stored • Collection of bytes interpreted as Single character Single word Single line Complete structure
  • 9. File (conti) • Last byte of file contains end of file character (EOF) • Can be used to check to know the end • Structure pointer of file type –to declare a file Eg:-FILE *fp Fp=fopen();
  • 10. File handling • Fopen() -create or open a file • Fclose() -close a file • Getc() -reads a character from a file • Putc() -writes a character to a file • Fscanf() -reads a set of data from a file • Fprintf() -writes a set of data to a file • Getw() -reads an integer from a file • Putw() -writes an integer to a file • Fseek() -set the position to desire point • Ftell() -gives current position in the file • Rewind() -set the position to the begning
  • 11. Two kindes of files • Text(ASCII) • Binary(non ASCII) -image,audio,vedio,executable,etc
  • 12. Fopen() • To create a new file or to open an existing file Syntax Fopen(filename,mode); Eg:-fp=fopen(“data.txt”,”r”); Return NULL-unable to open
  • 13. modes 1. r –opens file for reading 2. w-creates a file writing , over writes on previous content(delete) 3. a-opens a file for appending-writing on the end of file • “+” character-read & write • Can add a “b” character(non asci) –file is a binary -”rb” , ”wb” or “ab”
  • 14. Fclose() • Close an opened file Syntax Fclose(pointer_name); Eg:-fclose(fp); • Return zero on success • Return EOF on error
  • 15. Writing to a file&Reading data from a file Fprintf() & fscanf() • Just like printf() & scanf() Eg:-fprintf(fp,”babtra”); Eg:-fscanf(fp,”%s”,variable); • Except-first argument:file pointer Fputs()&fgets() Fputc()&fgetc()
  • 16. Example #include<stdio.h> void main() { char name[50]; FILE *fp; fp=fopen("yasir.txt","r+"); fprintf(fp,"hello_yasirn"); rewind(fp); fscanf(fp,"%s",name); printf("%s",name); fclose(fp); }
  • 17. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 18. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NIT-TBI, NIT Campus, Kozhikode, Kerala, India.