SlideShare a Scribd company logo
Cpu(2110003)
Group Project
“12.File Management”
Branch : Mech I-3
Prepared By: Jani Parth U.(150120119051)
Jerin Sibi.(150120119052)
Joshi Parth.(150120119053)
Guided By: Prof. Raxit Jani
INTRODUCTION
 Until Now We Have Been Using The Function Such As Scanf
And Printf To Read And Write Data. These Are Console
Oriented I/O Functions, Which Always Use The Terminal As
The Target.
 The Console Oriented I/O Pose Two Major Problem:
1. It Becomes Complex And Time Consuming To Handle Large
Volume Of Data Through Terminal.
2. The Entire Data Is Lost When Either The Program Is
Terminated.
A File Is A Place On The Disk Where A Group
Of Related Data Is Stored. Like Other
Language C Supports A Number Of Function
That Has The Ability To Perform Basic File
Operation, Which Include:
1. Naming A File
2. Opening A File
3. Reading Data
4. Writing Data
5. Closing A File
FUNCTION NAME OPERATION
 fopen()  Creates a new file for use.
 fclose()  Close a file which is open for use.
 getc()  Reads a character from file.
 putc()  Writes a character to a file.
 fprint()  Writes a set of data values to the file.
 fscanf()  Reads a set of data value from a file.
 getw()  Read an integer from the file.
HIGH LEVEL I/O
FUNCTION
DEFINING AND OPENING A FILE
If we want to store data in a file in the secondary memory,
we must specify certain things about the file. They include:
1) FILENAME
2) DATA STRUCTURE
3) PURPOSE
DATA STRUCTURE OF A FILE IS DEFINED AS FILE. FOLLOWING is
the general format for declaring and opening a file.
 FILE *fp;
 fp = fopen(“filename” , “mode”);
CLOSING A FILE
A file must be closed as soon as operation on it have
been completed. Another instance where we have to
close a file is when we want to reopen it.
The I/O library supports a function to do this for us. It
takes the following forms:
fclose(file_ pointer);
GETC AND PUTC FUNCTION
 The simplest file I/O functions are getc and putc. These are
the getchar and putchar functions and handle one character
at a time. The statement:
putc(c , fp1);
 Similarly, getc is used to read the character from a file that
has been opened in read mode. The statement:
c= getc(fp2) ;
GETW AND PUTW FUNCTION
The getw and putw are integer-oriented functions.
They are similar to the getc and putc functions
and are used to read and write integer values. The
general form are:
putw(integer ,fp);
getw(fp);
THE fprintf and fscanf FUNCTION
 The function fprintf and fscanf perform I/O operation that
are identical to the familiar printf and scanf functions,
except of course that they work on files. The general form:
fprintf(fp , “control strings” ,list);
 The list may include constant, variable and strings. The
general format of fscanf is:
fprintf(fp , “control strings” ,list);
ERROR HANDLING DURING I/O OPERATOR
It is possible an error may occur during I/O
operation on a file. They are:
1) Trying to read beyond the end- of- line mark.
2) Device overflow
3) Trying to use a file that has not been opened.
4) Trying to perform an operation on a file, when
the file is opened for another type of operation.
5) Opening a file with an invalid filename.
6) Attempting to write to a write-protected file.
RANDOM ACESS TO FILE
It can be achieved with the help of the functions fseek,
ftell, and rewind available in the I/O library.
Ftell takes a file pointer and return a number of type
long, that corresponds to the current position.
n = ftell(fp);
Rewind takes a file pointer and resets the position to
the start of the file.
rewind(fp);
n = ftell(fp);
fseek function is used to move the file position to a
desired location within the file.
fseek(file_ ptr , offset, position);
COMMAND LINE ARGUMENT
 It’s a parameter supplied to a program when the program is
invoked. For example , if we want to copy the contents of a file
X_FILE to another named Y_FILE, then:
C > PROGRAM X_ FILE Y_ FILE
 Where PROGRAM is the filename where the executable code of
the program is stored.
File Management

More Related Content

What's hot

File management in C++
File management in C++File management in C++
File management in C++
apoorvaverma33
 
File handling in c
File handling in cFile handling in c
File in c
File in cFile in c
File in c
Prabhu Govind
 
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
ٖFaiXy :)
 
File Handling in C
File Handling in C File Handling in C
File Handling in C
Subhanshu Maurya
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
Sonya Akter Rupa
 
File handling in C
File handling in CFile handling in C
File handling in C
Kamal Acharya
 
Lecture 20 - File Handling
Lecture 20 - File HandlingLecture 20 - File Handling
Lecture 20 - File Handling
Md. Imran Hossain Showrov
 
File operations in c
File operations in cFile operations in c
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
eShikshak
 
FILES IN C
FILES IN CFILES IN C
FILES IN C
yndaravind
 
File handling in c
File handling in cFile handling in c
File handling in c
David Livingston J
 
File handling in c
File handling in c File handling in c
File handling in c
Vikash Dhal
 
1file handling
1file handling1file handling
1file handling
Frijo Francis
 
C files
C filesC files
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
thirumalaikumar3
 
File handling-c
File handling-cFile handling-c
File handling
File handlingFile handling
File handling
Ans Ali
 
file
filefile
file
teach4uin
 
6. chapter v
6. chapter v6. chapter v
6. chapter v
Chhom Karath
 

What's hot (20)

File management in C++
File management in C++File management in C++
File management in C++
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File in c
File in cFile in c
File in c
 
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
 
File Handling in C
File Handling in C File Handling in C
File Handling in C
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
File handling in C
File handling in CFile handling in C
File handling in C
 
Lecture 20 - File Handling
Lecture 20 - File HandlingLecture 20 - File Handling
Lecture 20 - File Handling
 
File operations in c
File operations in cFile operations in c
File operations in c
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
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
 
File handling in c
File handling in c File handling in c
File handling in c
 
1file handling
1file handling1file handling
1file handling
 
C files
C filesC files
C files
 
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
 
File handling-c
File handling-cFile handling-c
File handling-c
 
File handling
File handlingFile handling
File handling
 
file
filefile
file
 
6. chapter v
6. chapter v6. chapter v
6. chapter v
 

Similar to File Management

File management
File managementFile management
File management
lalithambiga kamaraj
 
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
sudhakargeruganti
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
File management
File managementFile management
File management
sumathiv9
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
Rajeshkumar Reddy
 
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
AssadLeo1
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
Mehul Desai
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
armaansohail9356
 
Topic - File operation.pptx
Topic - File operation.pptxTopic - File operation.pptx
Topic - File operation.pptx
Adnan al-emran
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
Vikram Nandini
 
Unit5
Unit5Unit5
Unit5
mrecedu
 
File in C language
File in C languageFile in C language
File in C language
Manash Kumar Mondal
 
Handout#01
Handout#01Handout#01
Handout#01
Sunita Milind Dol
 
Unit 8
Unit 8Unit 8
Files in C
Files in CFiles in C
Files in C
Prabu U
 
18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx
ChenamPawan
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
YOGESH SINGH
 
Programming in C
Programming in CProgramming in C
Programming in C
MalathiNagarajan20
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
Osmania University
 

Similar to File Management (20)

File management
File managementFile management
File management
 
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
 
File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
File management
File managementFile management
File management
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
 
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
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
 
Topic - File operation.pptx
Topic - File operation.pptxTopic - File operation.pptx
Topic - File operation.pptx
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
Unit5
Unit5Unit5
Unit5
 
File in C language
File in C languageFile in C language
File in C language
 
Handout#01
Handout#01Handout#01
Handout#01
 
Unit 8
Unit 8Unit 8
Unit 8
 
Files in C
Files in CFiles in C
Files in C
 
18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
 
Programming in C
Programming in CProgramming in C
Programming in C
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 

More from jani parth

kinematics of 8-axis robot for material handling applications
kinematics of 8-axis robot for material handling applicationskinematics of 8-axis robot for material handling applications
kinematics of 8-axis robot for material handling applications
jani parth
 
hydraulic symbols
hydraulic symbolshydraulic symbols
hydraulic symbols
jani parth
 
Terminology Of Spur Gear
Terminology Of Spur GearTerminology Of Spur Gear
Terminology Of Spur Gear
jani parth
 
CNC Part programming
CNC Part programmingCNC Part programming
CNC Part programming
jani parth
 
Ultrasonic machining
Ultrasonic machiningUltrasonic machining
Ultrasonic machining
jani parth
 
Vapor-compression refrigeration – Effect of parameter
Vapor-compression refrigeration – Effect of parameterVapor-compression refrigeration – Effect of parameter
Vapor-compression refrigeration – Effect of parameter
jani parth
 
Job evolution
Job evolutionJob evolution
Job evolution
jani parth
 
Fillet feature in solid works
Fillet feature in solid worksFillet feature in solid works
Fillet feature in solid works
jani parth
 
IC Engine emission
IC Engine emissionIC Engine emission
IC Engine emission
jani parth
 
Rotating unbalance system
Rotating unbalance systemRotating unbalance system
Rotating unbalance system
jani parth
 
Effectiveness and number of transfer units for Parallel flow
Effectiveness and number of transfer  units for Parallel flowEffectiveness and number of transfer  units for Parallel flow
Effectiveness and number of transfer units for Parallel flow
jani parth
 
Signal flow graph
Signal flow graphSignal flow graph
Signal flow graph
jani parth
 
hydraulic jack
hydraulic jackhydraulic jack
hydraulic jack
jani parth
 
Band brake or band and block brake
Band brake or band and block brakeBand brake or band and block brake
Band brake or band and block brake
jani parth
 
Casting Defects and Manufacturing Processes
Casting Defects and Manufacturing ProcessesCasting Defects and Manufacturing Processes
Casting Defects and Manufacturing Processes
jani parth
 
Welded Joint (Theory)
Welded Joint (Theory)Welded Joint (Theory)
Welded Joint (Theory)
jani parth
 
Reynolds Number And Experiment
Reynolds Number And ExperimentReynolds Number And Experiment
Reynolds Number And Experiment
jani parth
 
Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)
Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)
Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)
jani parth
 
Optical Flat And Optical Square
Optical Flat And Optical SquareOptical Flat And Optical Square
Optical Flat And Optical Square
jani parth
 
Relative velocities
Relative velocitiesRelative velocities
Relative velocities
jani parth
 

More from jani parth (20)

kinematics of 8-axis robot for material handling applications
kinematics of 8-axis robot for material handling applicationskinematics of 8-axis robot for material handling applications
kinematics of 8-axis robot for material handling applications
 
hydraulic symbols
hydraulic symbolshydraulic symbols
hydraulic symbols
 
Terminology Of Spur Gear
Terminology Of Spur GearTerminology Of Spur Gear
Terminology Of Spur Gear
 
CNC Part programming
CNC Part programmingCNC Part programming
CNC Part programming
 
Ultrasonic machining
Ultrasonic machiningUltrasonic machining
Ultrasonic machining
 
Vapor-compression refrigeration – Effect of parameter
Vapor-compression refrigeration – Effect of parameterVapor-compression refrigeration – Effect of parameter
Vapor-compression refrigeration – Effect of parameter
 
Job evolution
Job evolutionJob evolution
Job evolution
 
Fillet feature in solid works
Fillet feature in solid worksFillet feature in solid works
Fillet feature in solid works
 
IC Engine emission
IC Engine emissionIC Engine emission
IC Engine emission
 
Rotating unbalance system
Rotating unbalance systemRotating unbalance system
Rotating unbalance system
 
Effectiveness and number of transfer units for Parallel flow
Effectiveness and number of transfer  units for Parallel flowEffectiveness and number of transfer  units for Parallel flow
Effectiveness and number of transfer units for Parallel flow
 
Signal flow graph
Signal flow graphSignal flow graph
Signal flow graph
 
hydraulic jack
hydraulic jackhydraulic jack
hydraulic jack
 
Band brake or band and block brake
Band brake or band and block brakeBand brake or band and block brake
Band brake or band and block brake
 
Casting Defects and Manufacturing Processes
Casting Defects and Manufacturing ProcessesCasting Defects and Manufacturing Processes
Casting Defects and Manufacturing Processes
 
Welded Joint (Theory)
Welded Joint (Theory)Welded Joint (Theory)
Welded Joint (Theory)
 
Reynolds Number And Experiment
Reynolds Number And ExperimentReynolds Number And Experiment
Reynolds Number And Experiment
 
Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)
Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)
Convergence Of Power Series , Taylor And Laurent Theorems (Without Proof)
 
Optical Flat And Optical Square
Optical Flat And Optical SquareOptical Flat And Optical Square
Optical Flat And Optical Square
 
Relative velocities
Relative velocitiesRelative velocities
Relative velocities
 

Recently uploaded

一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 
一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理
一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理
一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理
dtagbe
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
KubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial IntelligentKubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial Intelligent
Emre Gündoğdu
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
cyber crime.pptx..........................
cyber crime.pptx..........................cyber crime.pptx..........................
cyber crime.pptx..........................
GNAMBIKARAO
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 
How to make a complaint to the police for Social Media Fraud.pdf
How to make a complaint to the police for Social Media Fraud.pdfHow to make a complaint to the police for Social Media Fraud.pdf
How to make a complaint to the police for Social Media Fraud.pdf
Infosec train
 

Recently uploaded (12)

一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 
一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理
一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理
一比一原版(uc毕业证书)加拿大卡尔加里大学毕业证如何办理
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
KubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial IntelligentKubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial Intelligent
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
cyber crime.pptx..........................
cyber crime.pptx..........................cyber crime.pptx..........................
cyber crime.pptx..........................
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 
How to make a complaint to the police for Social Media Fraud.pdf
How to make a complaint to the police for Social Media Fraud.pdfHow to make a complaint to the police for Social Media Fraud.pdf
How to make a complaint to the police for Social Media Fraud.pdf
 

File Management

  • 1. Cpu(2110003) Group Project “12.File Management” Branch : Mech I-3 Prepared By: Jani Parth U.(150120119051) Jerin Sibi.(150120119052) Joshi Parth.(150120119053) Guided By: Prof. Raxit Jani
  • 2. INTRODUCTION  Until Now We Have Been Using The Function Such As Scanf And Printf To Read And Write Data. These Are Console Oriented I/O Functions, Which Always Use The Terminal As The Target.  The Console Oriented I/O Pose Two Major Problem: 1. It Becomes Complex And Time Consuming To Handle Large Volume Of Data Through Terminal. 2. The Entire Data Is Lost When Either The Program Is Terminated.
  • 3. A File Is A Place On The Disk Where A Group Of Related Data Is Stored. Like Other Language C Supports A Number Of Function That Has The Ability To Perform Basic File Operation, Which Include: 1. Naming A File 2. Opening A File 3. Reading Data 4. Writing Data 5. Closing A File
  • 4. FUNCTION NAME OPERATION  fopen()  Creates a new file for use.  fclose()  Close a file which is open for use.  getc()  Reads a character from file.  putc()  Writes a character to a file.  fprint()  Writes a set of data values to the file.  fscanf()  Reads a set of data value from a file.  getw()  Read an integer from the file. HIGH LEVEL I/O FUNCTION
  • 5. DEFINING AND OPENING A FILE If we want to store data in a file in the secondary memory, we must specify certain things about the file. They include: 1) FILENAME 2) DATA STRUCTURE 3) PURPOSE DATA STRUCTURE OF A FILE IS DEFINED AS FILE. FOLLOWING is the general format for declaring and opening a file.  FILE *fp;  fp = fopen(“filename” , “mode”);
  • 6. CLOSING A FILE A file must be closed as soon as operation on it have been completed. Another instance where we have to close a file is when we want to reopen it. The I/O library supports a function to do this for us. It takes the following forms: fclose(file_ pointer);
  • 7. GETC AND PUTC FUNCTION  The simplest file I/O functions are getc and putc. These are the getchar and putchar functions and handle one character at a time. The statement: putc(c , fp1);  Similarly, getc is used to read the character from a file that has been opened in read mode. The statement: c= getc(fp2) ;
  • 8. GETW AND PUTW FUNCTION The getw and putw are integer-oriented functions. They are similar to the getc and putc functions and are used to read and write integer values. The general form are: putw(integer ,fp); getw(fp);
  • 9. THE fprintf and fscanf FUNCTION  The function fprintf and fscanf perform I/O operation that are identical to the familiar printf and scanf functions, except of course that they work on files. The general form: fprintf(fp , “control strings” ,list);  The list may include constant, variable and strings. The general format of fscanf is: fprintf(fp , “control strings” ,list);
  • 10. ERROR HANDLING DURING I/O OPERATOR It is possible an error may occur during I/O operation on a file. They are: 1) Trying to read beyond the end- of- line mark. 2) Device overflow 3) Trying to use a file that has not been opened. 4) Trying to perform an operation on a file, when the file is opened for another type of operation. 5) Opening a file with an invalid filename. 6) Attempting to write to a write-protected file.
  • 11. RANDOM ACESS TO FILE It can be achieved with the help of the functions fseek, ftell, and rewind available in the I/O library. Ftell takes a file pointer and return a number of type long, that corresponds to the current position. n = ftell(fp); Rewind takes a file pointer and resets the position to the start of the file. rewind(fp); n = ftell(fp); fseek function is used to move the file position to a desired location within the file. fseek(file_ ptr , offset, position);
  • 12. COMMAND LINE ARGUMENT  It’s a parameter supplied to a program when the program is invoked. For example , if we want to copy the contents of a file X_FILE to another named Y_FILE, then: C > PROGRAM X_ FILE Y_ FILE  Where PROGRAM is the filename where the executable code of the program is stored.