SlideShare a Scribd company logo
INTRODUCTION TO FILE HANDLING
Presentation topic:-
Submitted by Guided by
Vikash Maurya 👨 👸
CONTENTS 👉
1⃣ What is file?
2⃣ Need of file in C programming.
3⃣ Data organization.
4⃣ File operations.
5⃣ Creating a new file by C.
6⃣ Writing, Reading and Append operation in the file.
7⃣ Closing a file.
WHAT IS FILE? 🤔
 A file is a collection of related data that a computer
treats as a single unit.
 Computer store files to secondary storage so that
the contents of files remain intact when a computer
shuts down.
 When a computer reads a file, it copies the file from
the storage device to memory; when it writes to a
file, it transfers data from memory to the storage
device.
 C uses a structure called FILE (defined in stdio.h)
to store the attributes of a file.
NEED OF FILE IN C PROGRAMMING 📂
Often it is not enough to just display the data on the
screen. Because if the data is large, only few of it
can be stored and displayed on the screen. Here
memory is volatile so the contents would be lost
once the program is terminated. So if we need the
same data we need to re-enter it or regenerate the
program. And to redo the process is time wasting.
And if we would have saved it to a media where the
data can be recoverable, it would help us. This
medium is usually a ‘file’ on the disk.
DATA ORGANIZATION 💻
Before we start doing input/output let us first find out
how data is organized on the disk. Here is the
solution-
Our program
C Library
functions
OS Disk
FILE OPERATIONS 🔧
There are different operations that can be carried out
in a file.
These are:
(a) Creation of a new file.
(b) Opening an existing file.
(c) Writing to a file.
(d) Reading form a file.
(e) Closing a file.
PROGRAM TO CREATE A FILE 📣
 /* C program to create a file called emp.rec and store information
 * about a person, in terms of his name, age and salary */
 #include <stdio.h>
 #include <conio.h>
 void main()
 {
 FILE *fptr;
 char name[20];
 int age;
 float salary;
 /* open for writing */
 fptr = fopen("emp.c", "w");
 printf("Enter the name n");
 scanf("%s", name);
 fprintf(fptr, "Name = %sn", name);
 printf("Enter the agen");
 scanf("%d", &age);
 fprintf(fptr, "Age = %dn", age);
 printf("Enter the salaryn");
 scanf("%f", &salary);
 fprintf(fptr, "Salary = %.2fn", salary);
 fclose(fptr);
 }
OUTPUT 🔭
FILE
/*FOR READING A SAVED FILE*/
 #include <stdio.h>
 #include <conio.h>
 void main()
 {
 FILE *fptr;
 char a;
 fptr=fopen("emp.c","r");
 while(1)
 {
 a=fgetc(fptr);
 if(a==EOF)
 break;
 printf("%c",a);
 }
 printf("n");
 fclose(fptr);
 getch();
 }
OUTPUT 🔬
/*PROGRAM IN APPEND MODE*/
 #include <stdio.h>
 #include <conio.h>
 void main()
 {
 FILE *fptr;
 char name[20];
 int age;
 float salary;
 fptr = fopen("emp.c", “a");
 printf("Enter the name n");
 scanf("%s", name);
 fprintf(fptr, "Name = %sn", name);
 printf("Enter the agen");
 scanf("%d", &age);
 fprintf(fptr, "Age = %dn", age);
 printf("Enter the salaryn");
 scanf("%f", &salary);
 fprintf(fptr, "Salary = %.2fn", salary);
 fclose(fptr);
 }
OUTPUT 🎥
FILE
FILE OPEN MODE 📌
MORE ON FILE OPEN MODE 📡
CLOSING A FILE 🔓
 When we finish with a mode, we need to close the
file before ending the program or beginning another
mode with that same file.
 To close a file, we use fclose.
Introduction of file handling

More Related Content

PDF
Php file handling in Hindi
PPTX
Php File Operations
PPTX
File upload for the 21st century
PDF
Plone Conference 2008 Lightning Talk Static Zope Rpx
PDF
File operations
PPTX
Linked data and rdf
PDF
Switch from shapefile
PDF
Php file handling in Hindi
Php File Operations
File upload for the 21st century
Plone Conference 2008 Lightning Talk Static Zope Rpx
File operations
Linked data and rdf
Switch from shapefile

What's hot (17)

PPTX
Pivotal greenplum external tables
PPT
PHP - Introduction to File Handling with PHP
PPT
Presentation on files
PDF
비윈도우즈 환경의 기술 서적 번역 도구 경험 공유
PPT
php file uploading
PPT
Filing system in PHP
PPT
Php i basic chapter 4
PPTX
Python data file handling
ODT
Huong dan cai dat hadoop
PDF
Class 7b: Files & File I/O
TXT
Fileinc
PPTX
FormatJS - JSConf Argentina
PPTX
File handling in c language
ODP
Oop bullets graphical
PPTX
Information Gathering
PPTX
RSS feeds using Millennium data
Pivotal greenplum external tables
PHP - Introduction to File Handling with PHP
Presentation on files
비윈도우즈 환경의 기술 서적 번역 도구 경험 공유
php file uploading
Filing system in PHP
Php i basic chapter 4
Python data file handling
Huong dan cai dat hadoop
Class 7b: Files & File I/O
Fileinc
FormatJS - JSConf Argentina
File handling in c language
Oop bullets graphical
Information Gathering
RSS feeds using Millennium data
Ad

Similar to Introduction of file handling (20)

PPTX
Programming C- File Handling , File Operation
PPTX
want to learn files,then just use this ppt to learn
PPTX
File handling in c Programming - Unit 5.1
PPTX
Concept of file handling in c
PDF
VIT351 Software Development VI Unit5
PPTX
File Handling and Preprocessor Directives
PPT
File Management
PPTX
INput output stream in ccP Full Detail.pptx
PPT
File handling in c
PPTX
File management
PPTX
PPS PPT 2.pptx
PPT
finally.c.ppt
PDF
637225560972186380.pdf
PPT
File management and handling by prabhakar
PDF
FILES IN C
DOCX
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
PPTX
Presentation of file handling in C language
PPTX
C-Programming File-handling-C.pptx
PPTX
C-Programming File-handling-C.pptx
PPTX
MODULE 8-File and preprocessor.pptx for c program learners easy learning
Programming C- File Handling , File Operation
want to learn files,then just use this ppt to learn
File handling in c Programming - Unit 5.1
Concept of file handling in c
VIT351 Software Development VI Unit5
File Handling and Preprocessor Directives
File Management
INput output stream in ccP Full Detail.pptx
File handling in c
File management
PPS PPT 2.pptx
finally.c.ppt
637225560972186380.pdf
File management and handling by prabhakar
FILES IN C
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
Presentation of file handling in C language
C-Programming File-handling-C.pptx
C-Programming File-handling-C.pptx
MODULE 8-File and preprocessor.pptx for c program learners easy learning
Ad

More from VC Infotech (14)

PPTX
Covid-19
PPTX
Cyclotron
PPTX
Vector
PPTX
Function in c language(defination and declaration)
PPTX
E wallet
PPT
Gauss Divergence Therom
PPTX
Hotspot!
PPTX
Windows firewall
PPTX
Cloud computing
PPTX
computer Virus
PPT
Firewall protection
PPS
Frindship
PPTX
Vikash maurya
PPT
E wallet
Covid-19
Cyclotron
Vector
Function in c language(defination and declaration)
E wallet
Gauss Divergence Therom
Hotspot!
Windows firewall
Cloud computing
computer Virus
Firewall protection
Frindship
Vikash maurya
E wallet

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Machine Learning_overview_presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Assigned Numbers - 2025 - Bluetooth® Document
1. Introduction to Computer Programming.pptx
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Machine Learning_overview_presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
SOPHOS-XG Firewall Administrator PPT.pptx
Encapsulation_ Review paper, used for researhc scholars

Introduction of file handling

  • 1. INTRODUCTION TO FILE HANDLING Presentation topic:- Submitted by Guided by Vikash Maurya 👨 👸
  • 2. CONTENTS 👉 1⃣ What is file? 2⃣ Need of file in C programming. 3⃣ Data organization. 4⃣ File operations. 5⃣ Creating a new file by C. 6⃣ Writing, Reading and Append operation in the file. 7⃣ Closing a file.
  • 3. WHAT IS FILE? 🤔  A file is a collection of related data that a computer treats as a single unit.  Computer store files to secondary storage so that the contents of files remain intact when a computer shuts down.  When a computer reads a file, it copies the file from the storage device to memory; when it writes to a file, it transfers data from memory to the storage device.  C uses a structure called FILE (defined in stdio.h) to store the attributes of a file.
  • 4. NEED OF FILE IN C PROGRAMMING 📂 Often it is not enough to just display the data on the screen. Because if the data is large, only few of it can be stored and displayed on the screen. Here memory is volatile so the contents would be lost once the program is terminated. So if we need the same data we need to re-enter it or regenerate the program. And to redo the process is time wasting. And if we would have saved it to a media where the data can be recoverable, it would help us. This medium is usually a ‘file’ on the disk.
  • 5. DATA ORGANIZATION 💻 Before we start doing input/output let us first find out how data is organized on the disk. Here is the solution- Our program C Library functions OS Disk
  • 6. FILE OPERATIONS 🔧 There are different operations that can be carried out in a file. These are: (a) Creation of a new file. (b) Opening an existing file. (c) Writing to a file. (d) Reading form a file. (e) Closing a file.
  • 7. PROGRAM TO CREATE A FILE 📣  /* C program to create a file called emp.rec and store information  * about a person, in terms of his name, age and salary */  #include <stdio.h>  #include <conio.h>  void main()  {  FILE *fptr;  char name[20];  int age;  float salary;  /* open for writing */  fptr = fopen("emp.c", "w");  printf("Enter the name n");  scanf("%s", name);  fprintf(fptr, "Name = %sn", name);  printf("Enter the agen");  scanf("%d", &age);  fprintf(fptr, "Age = %dn", age);  printf("Enter the salaryn");  scanf("%f", &salary);  fprintf(fptr, "Salary = %.2fn", salary);  fclose(fptr);  }
  • 10. /*FOR READING A SAVED FILE*/  #include <stdio.h>  #include <conio.h>  void main()  {  FILE *fptr;  char a;  fptr=fopen("emp.c","r");  while(1)  {  a=fgetc(fptr);  if(a==EOF)  break;  printf("%c",a);  }  printf("n");  fclose(fptr);  getch();  }
  • 12. /*PROGRAM IN APPEND MODE*/  #include <stdio.h>  #include <conio.h>  void main()  {  FILE *fptr;  char name[20];  int age;  float salary;  fptr = fopen("emp.c", “a");  printf("Enter the name n");  scanf("%s", name);  fprintf(fptr, "Name = %sn", name);  printf("Enter the agen");  scanf("%d", &age);  fprintf(fptr, "Age = %dn", age);  printf("Enter the salaryn");  scanf("%f", &salary);  fprintf(fptr, "Salary = %.2fn", salary);  fclose(fptr);  }
  • 14. FILE
  • 16. MORE ON FILE OPEN MODE 📡
  • 17. CLOSING A FILE 🔓  When we finish with a mode, we need to close the file before ending the program or beginning another mode with that same file.  To close a file, we use fclose.