SlideShare une entreprise Scribd logo
1  sur  14
FILE MANAGEMENT
PROGRAMMING IN C
SUBMITTED BY,
MS. K. BANUPRIYA
ASSISTANT PROFESSOR OF INFORMATION TECHNOLOGY
BON SECOURS COLLEGE FOR WOMEN, THANJAVUR.
WHAT IS FILE?
A collection of data (or) Information stores in a system memory is
called file.
Eg: system memory (hard disk)
TYPES OF FILE
TEXT FILE
• .txt file
• Contents will be like
alphabets,digits & special
character
• Easily understand by human
being
• It provides less security
BINARY FILE
• .bin file
• Contents will be like(0’s&1’s)
• Easily understandable by
computer
• Its provide better security with
compared to text file
o When a program is terminated ; entrie data will be
lost; so, storing in a file will perserve your data even if
the program terminates
o You can easily move your data from one computer to
another computer without make.
Why file is required?
 Creating a new file
 Opening an existing file
 Reading from the file
 Writing to the file
 Deleting to the file
 Closing the file
File Operation in C
fopen() Open a newfile (or) existing file
fclose() Close the file
fprintf() Write the data into the file
fscanf() Read data from the file
fgetc() Reads a character from the file
fputs() Write a character into the file
Declaring & opening file
FILE * fptr; declaration of file
fptr= fopen (“Filename”,”Mode”);
r - open the file reading only
w - open the file for writing only
Type of mode of file in c:
Declaring of file
FILE * P1,*P2;
P1=fopen(“data”,”r”);
P2=fopen(“result”,”w”);
Fprintf() & fscanf() function
#include <stdio.h>
Void main()
{
FILE*f;
f= fopen(“f1.txt”,”w”);
Fprintf(f,”Welcome”);
Fclose(f);
}
Reading file fscanf() function
#include <stdio.h>
Void main()
{
FILE*f;
Char buff [255];
f=fopen(“f1.txt”,”r”);
While (fscanf (f,”%s”,buff)1=EOF)
{
Printf(“%s”,buff);
}
fclose(f);
}
Output:
Welcome
Program:
#include<stdio.h>
#include<conio.h>
Void main()
int age;
char name[20];
clrscr();
printf(“enter the name & age:”);
Scanf(“%sn”,&name);
Scanf(“%dn”,&age);
fp = fopen(“Demo.txt”,”w”);
fprintf(fp,”name:%sn age:%d”,name ,age);
fclose(fp);
getch();
}
Output:
Enter the name & age : Abi
23
TYPE OF FILE PROCESSING:
Data can be accessed in file there are 2 ways to access the
data in file.
Sequential Access file
Random Access file
SEQUENTIAL ACCESS FILE RANDOM ACCESS FILE
Data stored and retrieved in a
sequential manner
Data stored and retrieved in a random
manner
eg:
sample.txt
Apple
eg:
sample.bin
101101DAF11C
1111110000B
The functions are used for random access file processing:
fseek() – file seeking
ftell() – file position
rewind() – go to f
fseek() It is used for seeking the pointer
position the file at the sequential type
ftell()
 This function return the value of
the current pointer position
 The value is count from the
beginning of the file.
rewind()
This function is used to move the
file pointer to the beginning of the
given file
Thank You

Contenu connexe

Similaire à C-FILE MANAGEMENT.pptx

Similaire à C-FILE MANAGEMENT.pptx (20)

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
 
File handling-c
File handling-cFile handling-c
File handling-c
 
1file handling
1file handling1file handling
1file handling
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-dutt
 
Unit5
Unit5Unit5
Unit5
 
Files_in_C.ppt
Files_in_C.pptFiles_in_C.ppt
Files_in_C.ppt
 
File management and handling by prabhakar
File management and handling by prabhakarFile management and handling by prabhakar
File management and handling by prabhakar
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
Concept of file handling in c
Concept of file handling in cConcept of file handling in c
Concept of file handling in c
 
C-Programming File-handling-C.pptx
C-Programming  File-handling-C.pptxC-Programming  File-handling-C.pptx
C-Programming File-handling-C.pptx
 
C-Programming File-handling-C.pptx
C-Programming  File-handling-C.pptxC-Programming  File-handling-C.pptx
C-Programming File-handling-C.pptx
 
File Handling in C Programming for Beginners
File Handling in C Programming for BeginnersFile Handling in C Programming for Beginners
File Handling in C Programming for Beginners
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
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
 
File Management in C
File Management in CFile Management in C
File Management in C
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
File handling in 'C'
File handling in 'C'File handling in 'C'
File handling in 'C'
 
File Handling
File HandlingFile Handling
File Handling
 

Plus de banu236831 (8)

Web Design-III IT.ppt
Web Design-III IT.pptWeb Design-III IT.ppt
Web Design-III IT.ppt
 
os.ppt
os.pptos.ppt
os.ppt
 
pointer in c++ -banu.pptx
pointer in c++ -banu.pptxpointer in c++ -banu.pptx
pointer in c++ -banu.pptx
 
understanding-operating-systems-Banu.ppt
understanding-operating-systems-Banu.pptunderstanding-operating-systems-Banu.ppt
understanding-operating-systems-Banu.ppt
 
distributed os.ppt
distributed os.pptdistributed os.ppt
distributed os.ppt
 
Human Resource BPO.ppt
Human Resource BPO.pptHuman Resource BPO.ppt
Human Resource BPO.ppt
 
c programming language.pptx
c programming language.pptxc programming language.pptx
c programming language.pptx
 
NT-Soft-skills-PPT new.pptx
NT-Soft-skills-PPT new.pptxNT-Soft-skills-PPT new.pptx
NT-Soft-skills-PPT new.pptx
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

C-FILE MANAGEMENT.pptx

  • 1. FILE MANAGEMENT PROGRAMMING IN C SUBMITTED BY, MS. K. BANUPRIYA ASSISTANT PROFESSOR OF INFORMATION TECHNOLOGY BON SECOURS COLLEGE FOR WOMEN, THANJAVUR.
  • 2. WHAT IS FILE? A collection of data (or) Information stores in a system memory is called file. Eg: system memory (hard disk)
  • 3. TYPES OF FILE TEXT FILE • .txt file • Contents will be like alphabets,digits & special character • Easily understand by human being • It provides less security BINARY FILE • .bin file • Contents will be like(0’s&1’s) • Easily understandable by computer • Its provide better security with compared to text file
  • 4. o When a program is terminated ; entrie data will be lost; so, storing in a file will perserve your data even if the program terminates o You can easily move your data from one computer to another computer without make. Why file is required?
  • 5.  Creating a new file  Opening an existing file  Reading from the file  Writing to the file  Deleting to the file  Closing the file File Operation in C
  • 6. fopen() Open a newfile (or) existing file fclose() Close the file fprintf() Write the data into the file fscanf() Read data from the file fgetc() Reads a character from the file fputs() Write a character into the file
  • 7. Declaring & opening file FILE * fptr; declaration of file fptr= fopen (“Filename”,”Mode”); r - open the file reading only w - open the file for writing only Type of mode of file in c:
  • 8. Declaring of file FILE * P1,*P2; P1=fopen(“data”,”r”); P2=fopen(“result”,”w”);
  • 9. Fprintf() & fscanf() function #include <stdio.h> Void main() { FILE*f; f= fopen(“f1.txt”,”w”); Fprintf(f,”Welcome”); Fclose(f); }
  • 10. Reading file fscanf() function #include <stdio.h> Void main() { FILE*f; Char buff [255]; f=fopen(“f1.txt”,”r”); While (fscanf (f,”%s”,buff)1=EOF) { Printf(“%s”,buff); } fclose(f); } Output: Welcome
  • 11. Program: #include<stdio.h> #include<conio.h> Void main() int age; char name[20]; clrscr(); printf(“enter the name & age:”); Scanf(“%sn”,&name); Scanf(“%dn”,&age); fp = fopen(“Demo.txt”,”w”); fprintf(fp,”name:%sn age:%d”,name ,age); fclose(fp); getch(); } Output: Enter the name & age : Abi 23
  • 12. TYPE OF FILE PROCESSING: Data can be accessed in file there are 2 ways to access the data in file. Sequential Access file Random Access file SEQUENTIAL ACCESS FILE RANDOM ACCESS FILE Data stored and retrieved in a sequential manner Data stored and retrieved in a random manner eg: sample.txt Apple eg: sample.bin 101101DAF11C 1111110000B
  • 13. The functions are used for random access file processing: fseek() – file seeking ftell() – file position rewind() – go to f fseek() It is used for seeking the pointer position the file at the sequential type ftell()  This function return the value of the current pointer position  The value is count from the beginning of the file. rewind() This function is used to move the file pointer to the beginning of the given file